diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2015-09-17 22:27:22 -0700 |
---|---|---|
committer | Chris Dickens <christopher.a.dickens@gmail.com> | 2015-09-20 14:52:49 -0700 |
commit | e9a52c03ae3fecb51b882a807c427f4b4dfa2d1e (patch) | |
tree | d8daf2f08166e8265939ecbdba0f2d1891c90560 | |
parent | 3dbf0a9c5e772ffc8bbab499bcc0a81f5ccd96e3 (diff) | |
download | libusb-e9a52c03ae3fecb51b882a807c427f4b4dfa2d1e.tar.gz |
linux_usbfs: Add support for kernels that can reap after disconnect
For kernels that support the REAP_AFTER_DISCONNECT capability, it is
no longer necessary to use the nasty workaround that is the
usbi_handle_disconnect() function. All transfers can be properly
reaped as one would expect and will have an appropriate URB status.
Note that moving usbi_handle_disconnect() after the hotplug section
is fine because the hotplug disconnect message simply gets added to
the hotplug_msgs list to be processed the next time handle_events()
is called.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r-- | libusb/os/linux_usbfs.c | 8 | ||||
-rw-r--r-- | libusb/os/linux_usbfs.h | 1 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 1bfcdd0..0fc8083 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -2607,7 +2607,7 @@ static int op_handle_events(struct libusb_context *ctx, * doesn't try to remove it a second time */ usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->fd); hpriv->fd_removed = 1; - usbi_handle_disconnect(handle); + /* device will still be marked as attached if hotplug monitor thread * hasn't processed remove event yet */ usbi_mutex_static_lock(&linux_hotplug_lock); @@ -2615,7 +2615,11 @@ static int op_handle_events(struct libusb_context *ctx, linux_device_disconnected(handle->dev->bus_number, handle->dev->device_address, NULL); usbi_mutex_static_unlock(&linux_hotplug_lock); - continue; + + if (!(hpriv->caps & USBFS_CAP_REAP_AFTER_DISCONNECT)) { + usbi_handle_disconnect(handle); + continue; + } } do { diff --git a/libusb/os/linux_usbfs.h b/libusb/os/linux_usbfs.h index 43fe11b..7f397f9 100644 --- a/libusb/os/linux_usbfs.h +++ b/libusb/os/linux_usbfs.h @@ -125,6 +125,7 @@ struct usbfs_hub_portinfo { #define USBFS_CAP_BULK_CONTINUATION 0x02 #define USBFS_CAP_NO_PACKET_SIZE_LIM 0x04 #define USBFS_CAP_BULK_SCATTER_GATHER 0x08 +#define USBFS_CAP_REAP_AFTER_DISCONNECT 0x10 #define USBFS_DISCONNECT_CLAIM_IF_DRIVER 0x01 #define USBFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02 diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 031f02e..f7892d2 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11009 +#define LIBUSB_NANO 11010 |