USB: gadget: android: pass ctrl requests to accessory function when disabled
authorMike Lockwood <lockwood@android.com>
Wed, 7 Sep 2011 16:55:12 +0000 (09:55 -0700)
committerMike Lockwood <lockwood@android.com>
Wed, 7 Sep 2011 18:07:02 +0000 (11:07 -0700)
Signed-off-by: Mike Lockwood <lockwood@android.com>
drivers/usb/gadget/android.c

index b13633bb684aa9ed675b26a164dc1335933aefd5..b7e402921c65c777a28349ce9a888c0f1904f549 100644 (file)
@@ -87,8 +87,7 @@ struct android_usb_function {
 
        /* Optional: called when the configuration is removed */
        void (*unbind_config)(struct android_usb_function *, struct usb_configuration *);
-       /* Optional: handle ctrl requests before the device is configured
-        *      and/or before the function is enabled */
+       /* Optional: handle ctrl requests before the device is configured */
        int (*ctrlrequest)(struct android_usb_function *,
                                        struct usb_composite_dev *,
                                        const struct usb_ctrlrequest *);
@@ -1057,6 +1056,12 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
                }
        }
 
+       /* Special case the accessory function.
+        * It needs to handle control requests before it is enabled.
+        */
+       if (value < 0)
+               value = acc_ctrlrequest(cdev, c);
+
        if (value < 0)
                value = composite_setup(gadget, c);