Thomas Heijligen has uploaded this change for review.

View Change

ch341a_spi: libusb functions can handle all platforms

libusb_detach_kernel_driver() returns LIBUSB_ERROR_NOT_SUPPORTED on
unsupported platforms. That's fine. There is no need to call this
function only on Linux.

Change-Id: If6f19744503055ab8e22c863b31e696808e0407d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
---
M ch341a_spi.c
1 file changed, 3 insertions(+), 8 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/89/57889/1
diff --git a/ch341a_spi.c b/ch341a_spi.c
index 4a76286..43acaeb 100644
--- a/ch341a_spi.c
+++ b/ch341a_spi.c
@@ -20,7 +20,6 @@
#include <string.h>
#include <libusb.h>
#include "flash.h"
-#include "platform.h"
#include "programmer.h"

/* LIBUSB_CALL ensures the right calling conventions on libusb callbacks.
@@ -448,17 +447,13 @@
return -1;
}

-/* libusb_detach_kernel_driver() and friends basically only work on Linux. We simply try to detach on Linux
- * without a lot of passion here. If that works fine else we will fail on claiming the interface anyway. */
-#if IS_LINUX
+/* libusb_detach_kernel_driver() is only available on linux. Other platforms return
+ * LIBUSB_ERROR_NOT_SUPPORTED. That's fine. */
ret = libusb_detach_kernel_driver(handle, 0);
- if (ret == LIBUSB_ERROR_NOT_SUPPORTED) {
- msg_pwarn("Detaching kernel drivers is not supported. Further accesses may fail.\n");
- } else if (ret != 0 && ret != LIBUSB_ERROR_NOT_FOUND) {
+ if (ret != 0 && ret != LIBUSB_ERROR_NOT_FOUND && ret != LIBUSB_ERROR_NOT_SUPPORTED) {
msg_pwarn("Failed to detach kernel driver: '%s'. Further accesses will probably fail.\n",
libusb_error_name(ret));
}
-#endif

ret = libusb_claim_interface(handle, 0);
if (ret != 0) {

To view, visit change 57889. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If6f19744503055ab8e22c863b31e696808e0407d
Gerrit-Change-Number: 57889
Gerrit-PatchSet: 1
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-MessageType: newchange