--- local_tree.orig/drivers/usb/core/devio.c    2004-07-25 15:06:59.000000000 +0200
+++ local_tree/drivers/usb/core/devio.c 2004-07-25 23:49:54.978689141 +0200
@@ -785,14 +785,20 @@
 
 static int proc_setconfig(struct dev_state *ps, void __user *arg)
 {
-       unsigned int u;
-       int status = 0;
        struct usb_host_config *actconfig;
+       struct usb_device *dev = ps->dev;
+       int ret;
+       unsigned int u;
 
        if (get_user(u, (unsigned int __user *)arg))
                return -EFAULT;
 
-       actconfig = ps->dev->actconfig;
+       down(&dev->serialize);
+       if (!connected(dev)) {
+               ret = -ENODEV;
+               goto out;
+       }
+       actconfig = dev->actconfig;
  
        /* Don't touch the device if any interfaces are claimed.
         * It could interfere with other drivers' operations, and if
@@ -803,7 +809,7 @@
  
                for (i = 0; i < actconfig->desc.bNumInterfaces; ++i) {
                        if (usb_interface_claimed(actconfig->interface[i])) {
-                               dev_warn (&ps->dev->dev,
+                               dev_warn (&dev->dev,
                                        "usbfs: interface %d claimed "
                                        "while '%s' sets config #%d\n",
                                        actconfig->interface[i]
@@ -811,8 +817,8 @@
                                                ->desc.bInterfaceNumber,
                                        current->comm, u);
 #if 0  /* FIXME:  enable in 2.6.10 or so */
-                               status = -EBUSY;
-                               break;
+                               ret = -EBUSY;
+                               goto out;
 #endif
                        }
                }
@@ -821,14 +827,14 @@
        /* SET_CONFIGURATION is often abused as a "cheap" driver reset,
         * so avoid usb_set_configuration()'s kick to sysfs
         */
-       if (status == 0) {
-               if (actconfig && actconfig->desc.bConfigurationValue == u)
-                       status = usb_reset_configuration(ps->dev);
-               else
-                       status = usb_set_configuration(ps->dev, u);
-       }
+       if (actconfig && actconfig->desc.bConfigurationValue == u)
+               ret = usb_reset_configuration(dev);
+       else
+               ret = usb_set_configuration(dev, u);
 
-       return status;
+out:
+       up(&dev->serialize);
+       return ret;
 }
 
 static int proc_submiturb(struct dev_state *ps, void __user *arg)
@@ -1287,14 +1293,8 @@
                break;
 
        case USBDEVFS_SETCONFIGURATION:
-               down(&dev->serialize);
-               if (!connected(dev)) {
-                       up(&dev->serialize);
-                       return -ENODEV;
-               }
                snoop(&dev->dev, "%s: SETCONFIGURATION\n", __FUNCTION__);
                ret = proc_setconfig(ps, p);
-               up(&dev->serialize);
                break;
 
        case USBDEVFS_SUBMITURB:


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to