diff options
| author | Manu Gautam <mgautam@codeaurora.org> | 2018-11-09 14:58:37 +0530 |
|---|---|---|
| committer | Manu Gautam <mgautam@codeaurora.org> | 2018-11-09 15:02:43 +0530 |
| commit | de2b9b133098f89abccd5403473479250430415c (patch) | |
| tree | a99a30f92a151c9a9f94055f351383e75837cc13 | |
| parent | e2a4721cface6a4766945bea70259ae7aba06d81 (diff) | |
usb: gadget: Don't override config->MaxPower if specified
For various reasons, user may want to specify lower bMaxPower
using following sysfs attribute for a configuration:
"configs/c.1/MaxPower"
Driver currently ignores that and selects 500mA or 900mA based
on the connection speed. Fix this by no overriding bMaxPower
if config->MaxPower is non-zero.
Change-Id: I10b499b327d5c4e332df2ce435211144637c48d0
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
| -rw-r--r-- | drivers/usb/gadget/composite.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index bf9730884235..c2dac015c501 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -486,14 +486,19 @@ done: static u8 encode_bMaxPower(enum usb_device_speed speed, struct usb_configuration *c) { - unsigned val = CONFIG_USB_GADGET_VBUS_DRAW; + unsigned val = c->MaxPower; switch (speed) { case USB_SPEED_SUPER: - /* with super-speed report 900mA */ - val = SSUSB_GADGET_VBUS_DRAW; + /* with super-speed report 900mA if user hasn't specified */ + if (!val) + val = SSUSB_GADGET_VBUS_DRAW; + return (u8)(val / SSUSB_GADGET_VBUS_DRAW_UNITS); default: + if (!val) + val = CONFIG_USB_GADGET_VBUS_DRAW; + return DIV_ROUND_UP(val, HSUSB_GADGET_VBUS_DRAW_UNITS); } } |
