mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
ch341a_spi: replace active kernel driver detaching by automatic one
Let libusb_claim_interface() handle the kernel driver detaching for us by allowing automatic kernel driver detachment. Allow this on all platforms. Change-Id: If6f19744503055ab8e22c863b31e696808e0407d Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57889 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
c99945d962
commit
61181a72a4
15
ch341a_spi.c
15
ch341a_spi.c
@ -20,7 +20,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libusb.h>
|
#include <libusb.h>
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "platform.h"
|
|
||||||
#include "programmer.h"
|
#include "programmer.h"
|
||||||
|
|
||||||
/* LIBUSB_CALL ensures the right calling conventions on libusb callbacks.
|
/* LIBUSB_CALL ensures the right calling conventions on libusb callbacks.
|
||||||
@ -448,17 +447,11 @@ static int ch341a_spi_init(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libusb_detach_kernel_driver() and friends basically only work on Linux. We simply try to detach on Linux
|
ret = libusb_set_auto_detach_kernel_driver(handle, 1);
|
||||||
* without a lot of passion here. If that works fine else we will fail on claiming the interface anyway. */
|
if (ret != 0) {
|
||||||
#if IS_LINUX
|
msg_pwarn("Platform does not support detaching of USB kernel drivers.\n"
|
||||||
ret = libusb_detach_kernel_driver(handle, 0);
|
"If an unsupported driver is active, claiming of the interface may fail.\n");
|
||||||
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) {
|
|
||||||
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);
|
ret = libusb_claim_interface(handle, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user