This creates an unlocked version of usb_set_configuration() for general use inside usbcore ... fixes to usbfs, to the device reset code, and to enumeration logic will all work better when the caller locks before calling this code.
Eventually I'd expect usb_set_configuration() to disappear from the driver API -- usb_reset_configuration() is what the drivers really seem to need.
Please merge.
- Dave
--- 1.39/drivers/usb/core/message.c Sun Oct 26 14:51:28 2003
+++ edited/drivers/usb/core/message.c Sun Jan 4 10:58:02 2004
@@ -1034,6 +1034,8 @@
return 0;
}
+extern int __usb_set_configuration(struct usb_device *, int);
+
/**
* usb_set_configuration - Makes a particular device setting be current
* @dev: the device whose configuration is being updated
@@ -1070,12 +1072,20 @@
*/
int usb_set_configuration(struct usb_device *dev, int configuration)
{
- int i, ret;
- struct usb_host_config *cp = NULL;
-
+ int status;
+
/* dev->serialize guards all config changes */
down(&dev->serialize);
+ status = __usb_set_configuration(dev, configuration);
+ up(&dev->serialize);
+ return status;
+}
+int __usb_set_configuration(struct usb_device *dev, int configuration)
+{
+ int i, ret;
+ struct usb_host_config *cp = NULL;
+
for (i=0; i<dev->descriptor.bNumConfigurations; i++) {
if (dev->config[i].desc.bConfigurationValue == configuration) {
cp = &dev->config[i];
@@ -1141,7 +1151,6 @@
}
out:
- up(&dev->serialize);
return ret;
}
