usb: dwc3: gadget: modify the scale in vbus_draw callback
authorRay Chi <raychi@google.com>
Sat, 27 Mar 2021 18:28:08 +0000 (02:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Mar 2021 11:35:54 +0000 (13:35 +0200)
Currently, vbus_draw callback used wrong scale for power_supply.
The unit of power supply should be uA.
Therefore, this patch will fix this problem.

Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback")
Reported-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Ray Chi <raychi@google.com>
Link: https://lore.kernel.org/r/20210327182809.1814480-2-raychi@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/gadget.c

index e1442fc..8a361f0 100644 (file)
@@ -2536,7 +2536,7 @@ static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)
        if (!dwc->usb_psy)
                return -EOPNOTSUPP;
 
-       val.intval = mA;
+       val.intval = 1000 * mA;
        ret = power_supply_set_property(dwc->usb_psy, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &val);
 
        return ret;