usb: composite gadget: set vbus_draw current limitation during suspend
authorHao Wu <hao.wu@intel.com>
Mon, 29 Nov 2010 07:17:03 +0000 (15:17 +0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 1 Dec 2010 00:46:34 +0000 (16:46 -0800)
This patch modifies the composite gadget to set vbus_draw current limitation
during suspend state. This current limitation in suspend state shouldn't be
more than 2.5mA

Signed-off-by: Hao Wu <hao.wu@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/composite.c

index d3493fede64a1e62385bea58d7e47ee493464fb2..21dc0da36ab797e1953ebdc54ae259ba4c9b25ac 100644 (file)
@@ -1188,6 +1188,8 @@ composite_suspend(struct usb_gadget *gadget)
                composite->suspend(cdev);
 
        cdev->suspended = 1;
+
+       usb_gadget_vbus_draw(gadget, 2);
 }
 
 static void
@@ -1195,6 +1197,7 @@ composite_resume(struct usb_gadget *gadget)
 {
        struct usb_composite_dev        *cdev = get_gadget_data(gadget);
        struct usb_function             *f;
+       u8                              maxpower;
 
        /* REVISIT:  should we have config level
         * suspend/resume callbacks?
@@ -1207,6 +1210,11 @@ composite_resume(struct usb_gadget *gadget)
                        if (f->resume)
                                f->resume(f);
                }
+
+               maxpower = cdev->config->bMaxPower;
+
+               usb_gadget_vbus_draw(gadget, maxpower ?
+                       (2 * maxpower) : CONFIG_USB_GADGET_VBUS_DRAW);
        }
 
        cdev->suspended = 0;