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)
committerArve Hjønnevåg <arve@android.com>
Mon, 8 Feb 2010 23:09:02 +0000 (15:09 -0800)
Signed-off-by: Mike Lockwood <lockwood@android.com>
drivers/usb/gadget/composite.c

index 0dedc681fc30bf32cf5a00a8219dc9789a72de13..39f61affbae6109fc296a7b6ab3298f1991ef7f2 100644 (file)
@@ -836,6 +836,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;
        }