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>
This commit is contained in:
Chris Dickens 2015-09-17 22:27:22 -07:00
parent 3dbf0a9c5e
commit e9a52c03ae
3 changed files with 8 additions and 3 deletions

View file

@ -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,8 +2615,12 @@ 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);
if (!(hpriv->caps & USBFS_CAP_REAP_AFTER_DISCONNECT)) {
usbi_handle_disconnect(handle);
continue;
}
}
do {
r = reap_for_handle(handle);

View file

@ -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

View file

@ -1 +1 @@
#define LIBUSB_NANO 11009
#define LIBUSB_NANO 11010