]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
USB Gadget: Verify VBUS current before setting the device self-powered bit
authorParirajan Muthalagu <parirajan.muthalagu@stericsson.com>
Wed, 25 Aug 2010 11:03:26 +0000 (16:33 +0530)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 22 Oct 2010 17:21:20 +0000 (10:21 -0700)
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Praveena Nadahally <praveen.nadahally@stericsson.com>
Signed-off-by: Parirajan Muthalagu <parirajan.muthalagu@stericsson.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/composite.c
include/linux/usb/ch9.h

index 1160c55de7f280122038aa21ee063ac1cfa06cb3..eaa9a599df63707d94c82f80941cfc8d4c908f44 100644 (file)
@@ -1074,7 +1074,13 @@ static int composite_bind(struct usb_gadget *gadget)
        cdev->bufsiz = USB_BUFSIZ;
        cdev->driver = composite;
 
-       usb_gadget_set_selfpowered(gadget);
+       /*
+        * As per USB compliance update, a device that is actively drawing
+        * more than 100mA from USB must report itself as bus-powered in
+        * the GetStatus(DEVICE) call.
+        */
+       if (CONFIG_USB_GADGET_VBUS_DRAW <= USB_SELF_POWER_VBUS_MAX_DRAW)
+               usb_gadget_set_selfpowered(gadget);
 
        /* interface and string IDs start at zero via kzalloc.
         * we force endpoints to start unassigned; few controller
index da2ed77d3e8d35bf3d0aa023e90b3d266aec3ef2..b0f7e9f57176ab0e8d2832067a98f3061d8ff86f 100644 (file)
@@ -808,4 +808,14 @@ enum usb_device_state {
         */
 };
 
+/*-------------------------------------------------------------------------*/
+
+/*
+ * As per USB compliance update, a device that is actively drawing
+ * more than 100mA from USB must report itself as bus-powered in
+ * the GetStatus(DEVICE) call.
+ * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
+ */
+#define USB_SELF_POWER_VBUS_MAX_DRAW           100
+
 #endif /* __LINUX_USB_CH9_H */