modify power_supply usage in dwc3
Subsystems (3)
cover modify power_supply usage in dwc3
Currently, the power_supply usage in dwc3 is wrong. In addition, there is a build error when CONFIG_POWER_SUPPLY is not enabled. Therefore, these patches will fix the problems.
Ray Chi (2):
usb: dwc3: gadget: modify the scale in vbus_draw callback
power: supply: Fix build error when CONFIG_POWER_SUPPLY is not
enabled.
drivers/usb/dwc3/gadget.c | 2 +- include/linux/power_supply.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.0.291.g576ba9dcdaf-goog
PATCH 1/2 usb: dwc3: gadget: modify the scale in vbus_draw callback
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.
--- drivers/usb/dwc3/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/gadget.c +1 -1
@@ -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;
Signature · 1 line
2.31.0.291.g576ba9dcdaf-goog
PATCH 2/2 power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled.
In reply to Ray ChiThe build error happens when CONFIG_POWER_SUPPLY is not enabled.
h8300-linux-ld: drivers/usb/dwc3/gadget.o: in function `.L59':
Quoted 1 line
Quoted 1 line
gadget.c:(.text+0x655): undefined reference to `power_supply_set_property'
--- include/linux/power_supply.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/linux/power_supply.h +7 -0
@@ -426,9 +426,16 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }extern int power_supply_get_property (struct power_supply *psy,enum power_supply_property psp,union power_supply_propval *val); +#if IS_ENABLED (CONFIG_POWER_SUPPLY )extern int power_supply_set_property (struct power_supply *psy,enum power_supply_property psp,const union power_supply_propval *val); +#else +static inline int power_supply_set_property (struct power_supply *psy, +enum power_supply_property psp, +const union power_supply_propval *val) +{return 0 ; } +#endif extern int power_supply_property_is_writeable (struct power_supply *psy,enum power_supply_property psp);extern void power_supply_external_power_changed (struct power_supply *psy);
Signature · 1 line
2.31.0.291.g576ba9dcdaf-goog