tree 6413fc59dacef3d757f06252f57fdb3c153d1a8f
parent 3ea15966ed59f2bc20928c7b0496b4585f6de206
author Alan Stern <[EMAIL PROTECTED]> Thu, 11 Aug 2005 23:50:32 -0400
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Fri, 09 Sep 2005 06:28:22 -0700

[PATCH] USB: Support unbinding of the usb_generic driver

This patch (as556) adds support for unbinding the usb_generic "driver".
That driver only binds to USB devices, as opposed to interfaces, and it
does nothing much besides marking which struct device's go with an
overall USB device plus providing suspend/resume methods.  Now that
users can unbind drivers at will using the sysfs "unbind" attribute, we
need a rational way of dealing with USB devices that are no longer under
full control of the USB stack.  The patch handles this by unconfiguring
the device, thereby removing all the interfaces and their associated
drivers and children.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

 drivers/usb/core/usb.c |   10 ++++++++++
 1 files changed, 10 insertions(+)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -65,6 +65,16 @@ static int generic_probe (struct device 
 static int generic_remove (struct device *dev)
+       struct usb_device *udev = to_usb_device(dev);
+       /* if this is only an unbind, not a physical disconnect, then
+        * unconfigure the device */
+       if (udev->state == USB_STATE_CONFIGURED)
+               usb_set_configuration(udev, 0);
+       /* in case the call failed or the device was suspended */
+       if (udev->state >= USB_STATE_CONFIGURED)
+               usb_disable_device(udev, 0);
        return 0;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to