From fc51f19341af70508b94c06ff763842b396ea72e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 13 Jun 2013 21:21:14 +0200 Subject: libusb: Add auto-detach-kernel-driver functionality Add auto-detach-kernel-driver functionality, and a libusb_set_auto_detach_kernel_driver() function. Note that I went with a libusb_set_auto_detach_kernel_driver() function, rather then with a libusb_enable_auto_detach_kernel_driver(), so that apps can also disable it again. This is necessary to handle 2 corner cases: 1) When an app wants to do a libusb_set_configuration after claiming 1 or more interfaces, it needs to first release the interface(s), and in this case libusb_release_interface() should *not* (re-)attach the kernel driver 2) Some usb classes use multiple interfaces for one function, ie usb-audio devices do this. In this case attaching the driver will fail until all interfaces are released, so the app should first release all interfaces, and only then (re-)attach the kernel driver. auto-detach-kernel-driver functionality is still useful for these apps, since doing libusb_detach_kernel_driver() followed by libusb_claim_interface() in 2 separate calls is inherently racy, but they need to be able to disable the auto-detach functionality before releasing interfaces to be able to properly handle the 2 described corner cases. Signed-off-by: Hans de Goede --- libusb/libusb-1.0.def | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libusb/libusb-1.0.def') diff --git a/libusb/libusb-1.0.def b/libusb/libusb-1.0.def index e6c46fd..cb0e32a 100644 --- a/libusb/libusb-1.0.def +++ b/libusb/libusb-1.0.def @@ -130,6 +130,8 @@ EXPORTS libusb_release_interface@8 = libusb_release_interface libusb_reset_device libusb_reset_device@4 = libusb_reset_device + libusb_set_auto_detach_kernel_driver + libusb_set_auto_detach_kernel_driver@8 = libusb_set_auto_detach_kernel_driver libusb_set_configuration libusb_set_configuration@8 = libusb_set_configuration libusb_set_debug -- cgit v1.2.1