]> Pileus Git - ~andy/linux/commit
usbfs: Add a new disconnect-and-claim ioctl (v2)
authorHans de Goede <hdegoede@redhat.com>
Sat, 8 Sep 2012 18:02:05 +0000 (20:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 10 Sep 2012 18:10:37 +0000 (11:10 -0700)
commit0837e7e5270bd5547ba5763f11611dc43f677b3d
tree7815686351ce050a393cf5aecd52da5b92ea7119
parentba2f9dff6c914b91005f687a9d75c8eac110d323
usbfs: Add a new disconnect-and-claim ioctl (v2)

Apps which deal with devices which also have a kernel driver, need to do
the following:
1) Check which driver is attached, so as to not detach the wrong driver
   (ie detaching usbfs while another instance of the app is using the device)
2) Detach the kernel driver
3) Claim the interface

Where moving from one step to the next for both 1-2 and 2-3 consists of
a (small) race window. So currently such apps are racy and people just live
with it.

This patch adds a new ioctl which makes it possible for apps to do this
in a race free manner. For flexibility apps can choose to:
1) Specify the driver to disconnect
2) Specify to disconnect any driver except for the one named by the app
3) Disconnect any driver

Note that if there is no driver attached, the ioctl will just act like the
regular claim-interface ioctl, this is by design, as returning an error for
this condition would open a new bag of race-conditions.

Changes in v2:
-Fix indentation of if blocks where the condition spans multiple lines

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/devio.c
include/linux/usbdevice_fs.h