Linux: Add support for the new URB_BULK_CONTINUATION flag
authorDavid Moore <dcm@acm.org>
Fri, 6 Nov 2009 21:37:25 +0000 (21:37 +0000)
committerDaniel Drake <dsd@gentoo.org>
Fri, 6 Nov 2009 21:50:41 +0000 (21:50 +0000)
commit217f57617e0cff0d1bd6d726b243f04c6b179773
tree133b6b106ed8f9e15040ae33ac38c09a017f13d7
parent69830057547396f893f0d7b3125a05d016313b10
Linux: Add support for the new URB_BULK_CONTINUATION flag

Add support for the new USBDEVFS_URB_BULK_CONTINUATION flag to libusb.

This flag, which is expected to be available in usbfs starting with
kernel 2.6.32, allows the kernel to cancel multiple URBs upon receipt
of a short packet.  This capability allows libusb to preserve data
integrity of large bulk transfers that are split into multiple URBs.
Without this support, these URBs must be canceled in userspace upon
receipt of a short packet, a race condition against future transfers
which might partially fill these canceled URBs.

This patch automatically detects whether a supported kernel is present
and enables the use of the flag when possible.

[dsd: tweaks to supported kernel detection, and some inline
 documentation of this mechanism]
libusb/os/linux_usbfs.c
libusb/os/linux_usbfs.h