diff options
Diffstat (limited to 'examples/xusb.c')
-rw-r--r-- | examples/xusb.c | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/examples/xusb.c b/examples/xusb.c index 3d3b853..bdb9794 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -785,8 +785,6 @@ static int test_device(uint16_t vid, uint16_t pid) const struct libusb_endpoint_descriptor *endpoint; int i, j, k, r; int iface, nb_ifaces, first_iface = -1; - // For attaching/detaching the kernel driver, if needed - int iface_detached = -1; struct libusb_device_descriptor dev_desc; const char* speed_name[5] = { "Unknown", "1.5 Mbit/s (USB LowSpeed)", "12 Mbit/s (USB FullSpeed)", "480 Mbit/s (USB HighSpeed)", "5000 Mbit/s (USB SuperSpeed)"}; @@ -894,21 +892,11 @@ static int test_device(uint16_t vid, uint16_t pid) } libusb_free_config_descriptor(conf_desc); + libusb_set_auto_detach_kernel_driver(handle, 1); for (iface = 0; iface < nb_ifaces; iface++) { printf("\nClaiming interface %d...\n", iface); r = libusb_claim_interface(handle, iface); - if ((r != LIBUSB_SUCCESS) && libusb_has_capability(LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER) - && (libusb_kernel_driver_active(handle, iface) > 0)) { - // Try to detach the kernel driver - perr(" A kernel driver is active, trying to detach it...\n"); - r = libusb_detach_kernel_driver(handle, iface); - if (r == LIBUSB_SUCCESS) { - iface_detached = iface; - printf(" Claiming interface again...\n"); - r = libusb_claim_interface(handle, iface); - } - } if (r != LIBUSB_SUCCESS) { perr(" Failed.\n"); } @@ -957,11 +945,6 @@ static int test_device(uint16_t vid, uint16_t pid) libusb_release_interface(handle, iface); } - if (iface_detached >= 0) { - printf("Re-attaching kernel driver...\n"); - libusb_attach_kernel_driver(handle, iface_detached); - } - printf("Closing device...\n"); libusb_close(handle); |