mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
ch341a_spi: detach/attach kernel driver explicitly
Use `libusb_detach_kernel_driver` and `libusb_attach_kernel_driver` instead of `libusb_auto_detach_kernel_driver` to be compatible with older libusb versions without changing the behavior. TEST=Build with libusb >= 1.0.9 Read spi flash with ch341a programmer on linux Change-Id: Ia649722e64cc97c6b689dd3b764e5c9145959f92 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/67071 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
parent
0aa238faee
commit
5903bb829d
11
ch341a_spi.c
11
ch341a_spi.c
@ -398,6 +398,7 @@ static int ch341a_spi_shutdown(void *data)
|
||||
transfer_ins[i] = NULL;
|
||||
}
|
||||
libusb_release_interface(handle, 0);
|
||||
libusb_attach_kernel_driver(handle, 0);
|
||||
libusb_close(handle);
|
||||
libusb_exit(NULL);
|
||||
handle = NULL;
|
||||
@ -448,11 +449,10 @@ static int ch341a_spi_init(const struct programmer_cfg *cfg)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = libusb_set_auto_detach_kernel_driver(handle, 1);
|
||||
if (ret != 0) {
|
||||
msg_pwarn("Platform does not support detaching of USB kernel drivers.\n"
|
||||
"If an unsupported driver is active, claiming the interface may fail.\n");
|
||||
}
|
||||
ret = libusb_detach_kernel_driver(handle, 0);
|
||||
if (ret != 0 && ret != LIBUSB_ERROR_NOT_FOUND)
|
||||
msg_pwarn("Cannot detach the existing USB driver. Claiming the interface may fail. %s\n",
|
||||
libusb_error_name(ret));
|
||||
|
||||
ret = libusb_claim_interface(handle, 0);
|
||||
if (ret != 0) {
|
||||
@ -514,6 +514,7 @@ dealloc_transfers:
|
||||
release_interface:
|
||||
libusb_release_interface(handle, 0);
|
||||
close_handle:
|
||||
libusb_attach_kernel_driver(handle, 0);
|
||||
libusb_close(handle);
|
||||
handle = NULL;
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user