linux_usbfs: Add support for new disconnect-and-claim ioctl
authorHans de Goede <hdegoede@redhat.com>
Thu, 13 Jun 2013 19:49:01 +0000 (21:49 +0200)
committerHans de Goede <hdegoede@redhat.com>
Wed, 19 Jun 2013 09:04:15 +0000 (11:04 +0200)
commitd4e993192aa81a1867bddf90d53cf750ec21e7b1
tree1ba35c380272b8f492629c2a9614a602573018b9
parentfc51f19341af70508b94c06ff763842b396ea72e
linux_usbfs: Add support for new disconnect-and-claim ioctl

Currently the linux_usbfs detach_kernel_driver_and_claim() helper function
makes 3 system calls:
1) IOCTL_USBFS_GETDRIVER, to check the driver is not usbfs
2) IOCTL_USBFS_DISCONNECT
3) IOCTL_USBFS_CLAIMINTF

Between each of these calls the state of the interface can change, and
things might not work as expected when it does, iow this is inherently racy.

To fix this a new IOCTL_USBFS_DISCONNECT_CLAIM ioctl has been added to the
kernel a while back, which does all 3 in one. This patch adds support for
this ioctl, with a fall back to the old method for kernels lacking this new
ioctl.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/os/linux_usbfs.c
libusb/os/linux_usbfs.h
libusb/version_nano.h