USB: composite: Allow configurations to handle unhandled setup requests
authorJoe Swantek <joseph.swantek@motorola.com>
Tue, 15 Dec 2009 12:17:40 +0000 (07:17 -0500)
committerColin Cross <ccross@android.com>
Thu, 30 Sep 2010 00:49:16 +0000 (17:49 -0700)
Signed-off-by: Mike Lockwood <lockwood@android.com>
drivers/usb/gadget/composite.c

index 1659a11dc18cb3f3e2131ac87a2b3a636d988528..e69a0ac3bf6fbc2f8ff733bf631f82a127b93467 100644 (file)
@@ -937,6 +937,25 @@ unknown:
                                value = c->setup(c, ctrl);
                }
 
+               /* If the vendor request is not processed (value < 0),
+                * call all device registered configure setup callbacks
+                * to process it.
+                * This is used to handle the following cases:
+                * - vendor request is for the device and arrives before
+                * setconfiguration.
+                * - Some devices are required to handle vendor request before
+                * setconfiguration such as MTP, USBNET.
+                */
+
+               if (value < 0) {
+                       struct usb_configuration        *cfg;
+
+                       list_for_each_entry(cfg, &cdev->configs, list) {
+                       if (cfg && cfg->setup)
+                               value = cfg->setup(cfg, ctrl);
+                       }
+               }
+
                goto done;
        }