diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-06-14 09:56:20 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-07-12 11:42:01 +0200 |
commit | 050f32a35898c8ac8ac47322f21f0ec4928aa065 (patch) | |
tree | 7f93b89ab9300beccae2c9addc823376bb93244e | |
parent | 3f85be6da588d17f272a4b3c9b34bbfb7510f1e7 (diff) |
usbredirhost: Use libusb_set_auto_detach_kernel_driver when available
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | usbredirhost/usbredirhost.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c index 09745c2..0335b37 100644 --- a/usbredirhost/usbredirhost.c +++ b/usbredirhost/usbredirhost.c @@ -499,9 +499,13 @@ static int usbredirhost_claim(struct usbredirhost *host, int initial_claim) memset(host->alt_setting, 0, MAX_INTERFACES); host->claimed = 1; +#if LIBUSBX_API_VERSION >= 0x01000102 + libusb_set_auto_detach_kernel_driver(host->handle, 1); +#endif for (i = 0; host->config && i < host->config->bNumInterfaces; i++) { n = host->config->interface[i].altsetting[0].bInterfaceNumber; +#if LIBUSBX_API_VERSION < 0x01000102 r = libusb_detach_kernel_driver(host->handle, n); if (r < 0 && r != LIBUSB_ERROR_NOT_FOUND && r != LIBUSB_ERROR_NOT_SUPPORTED) { @@ -509,6 +513,7 @@ static int usbredirhost_claim(struct usbredirhost *host, int initial_claim) n, host->config->bConfigurationValue, libusb_error_name(r)); return libusb_status_or_error_to_redir_status(host, r); } +#endif r = libusb_claim_interface(host->handle, n); if (r < 0) { @@ -534,6 +539,16 @@ static void usbredirhost_release(struct usbredirhost *host, int attach_drivers) if (!host->claimed) return; +#if LIBUSBX_API_VERSION >= 0x01000102 + /* We want to always do the attach ourselves because: + 1) For compound interfaces such as usb-audio we must first release all + interfaces before we can attach the driver; + 2) When releasing interfaces before calling libusb_set_configuration, + we don't want the kernel driver to get attached (our attach_drivers + parameter is 0 in this case). */ + libusb_set_auto_detach_kernel_driver(host->handle, 0); +#endif + for (i = 0; host->config && i < host->config->bNumInterfaces; i++) { n = host->config->interface[i].altsetting[0].bInterfaceNumber; |