diff options
author | Thomas Heijligen <thomas.heijligen@secunet.com> | 2022-08-25 13:05:39 +0200 |
---|---|---|
committer | Thomas Heijligen <src@posteo.de> | 2022-09-07 11:28:03 +0000 |
commit | 5903bb829d8bf67aee290ff4ef141fd76507767c (patch) | |
tree | 7b49c9fb59aa9bd43bc5ae7f42e44670c1ba0af4 /ch341a_spi.c | |
parent | 0aa238faee81bbca967417be2eca4e6a179fc3e6 (diff) | |
download | flashrom-5903bb829d8bf67aee290ff4ef141fd76507767c.tar.gz flashrom-5903bb829d8bf67aee290ff4ef141fd76507767c.tar.bz2 flashrom-5903bb829d8bf67aee290ff4ef141fd76507767c.zip |
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>
Diffstat (limited to 'ch341a_spi.c')
-rw-r--r-- | ch341a_spi.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ch341a_spi.c b/ch341a_spi.c index 78b9cee6c..48c642079 100644 --- a/ch341a_spi.c +++ b/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; |