diff options
author | Pete Batard <pbatard@gmail.com> | 2010-03-01 16:43:48 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-03-01 16:43:48 +0000 |
commit | 1c727411238253a5d6f734c7c5c7ac3ca0054544 (patch) | |
tree | 214272d7aecd4c7f5c08f58d0a2fa809f1a80025 /examples | |
parent | 158799ca3f9edb946f152dccb5d9f0a3d607fa0c (diff) | |
download | libusb-1c727411238253a5d6f734c7c5c7ac3ca0054544.tar.gz |
reattach driver when detached in xusb (Xiaofan Chen)r183
Diffstat (limited to 'examples')
-rw-r--r-- | examples/xusb.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/xusb.c b/examples/xusb.c index e53b474..6bc3b4f 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -553,6 +553,9 @@ int test_device(uint16_t vid, uint16_t pid) const struct libusb_endpoint_descriptor *endpoint; int i, j, k, r; int iface, nb_ifaces, nb_strings; +#ifndef OS_WINDOWS + int iface_detached = -1; +#endif int test_scsi = 0; struct libusb_device_descriptor dev_desc; char string[128]; @@ -624,6 +627,7 @@ int test_device(uint16_t vid, uint16_t pid) // Maybe we need to detach the driver perr(" Failed. Trying to detach driver...\n"); libusb_detach_kernel_driver(handle, iface); + iface_detached = iface; printf(" Claiming interface again...\n"); libusb_claim_interface(handle, iface); } else { @@ -668,6 +672,13 @@ int test_device(uint16_t vid, uint16_t pid) libusb_release_interface(handle, iface); } +#ifndef OS_WINDOWS + if (iface_detached >= 0) { + printf("Re-attaching kernel driver...\n"); + libusb_attach_kernel_driver(handle, iface_detached); + } +#endif + printf("Closing device...\n"); libusb_close(handle); |