linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] modify power_supply usage in dwc3
@ 2021-03-27 18:28 Ray Chi
  2021-03-27 18:28 ` [PATCH 1/2] usb: dwc3: gadget: modify the scale in vbus_draw callback Ray Chi
  2021-03-27 18:28 ` [PATCH 2/2] power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled Ray Chi
  0 siblings, 2 replies; 3+ messages in thread
From: Ray Chi @ 2021-03-27 18:28 UTC (permalink / raw)
  To: balbi, gregkh, sre; +Cc: linux-usb, linux-kernel, kyletso, badhri, Ray Chi

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(-)

-- 
2.31.0.291.g576ba9dcdaf-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] usb: dwc3: gadget: modify the scale in vbus_draw callback
  2021-03-27 18:28 [PATCH 0/2] modify power_supply usage in dwc3 Ray Chi
@ 2021-03-27 18:28 ` Ray Chi
  2021-03-27 18:28 ` [PATCH 2/2] power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled Ray Chi
  1 sibling, 0 replies; 3+ messages in thread
From: Ray Chi @ 2021-03-27 18:28 UTC (permalink / raw)
  To: balbi, gregkh, sre; +Cc: linux-usb, linux-kernel, kyletso, badhri, Ray Chi

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>
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index e1442fc763e1..8a361f07e045 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -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;
-- 
2.31.0.291.g576ba9dcdaf-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled.
  2021-03-27 18:28 [PATCH 0/2] modify power_supply usage in dwc3 Ray Chi
  2021-03-27 18:28 ` [PATCH 1/2] usb: dwc3: gadget: modify the scale in vbus_draw callback Ray Chi
@ 2021-03-27 18:28 ` Ray Chi
  1 sibling, 0 replies; 3+ messages in thread
From: Ray Chi @ 2021-03-27 18:28 UTC (permalink / raw)
  To: balbi, gregkh, sre
  Cc: linux-usb, linux-kernel, kyletso, badhri, Ray Chi, kernel test robot

The build error happens when CONFIG_POWER_SUPPLY is not enabled.

h8300-linux-ld: drivers/usb/dwc3/gadget.o: in function `.L59':
>> gadget.c:(.text+0x655): undefined reference to `power_supply_set_property'

Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ray Chi <raychi@google.com>
---
 include/linux/power_supply.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 81a55e974feb..b495b4374cd0 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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);
-- 
2.31.0.291.g576ba9dcdaf-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-27 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-27 18:28 [PATCH 0/2] modify power_supply usage in dwc3 Ray Chi
2021-03-27 18:28 ` [PATCH 1/2] usb: dwc3: gadget: modify the scale in vbus_draw callback Ray Chi
2021-03-27 18:28 ` [PATCH 2/2] power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled Ray Chi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).