diff mbox series

[v1,2/2] usb: gadget: Retry populating usb-psy when null

Message ID 20231216034335.242168-2-badhri@google.com
State New
Headers show
Series [v1,1/2] usb: dwc3: Refactor usb-psy init | expand

Commit Message

Badhri Jagan Sridharan Dec. 16, 2023, 3:43 a.m. UTC
This patch allows populating usb-psy where usb-psy comes up
after dwc3 is probed. Retry populating usb-psy when dwc->usb_psy
is null while dwc3_gadget_vbus_draw() is executed.

Cc: stable@vger.kernel.org
Fixes: 99288de36020 ("usb: dwc3: add an alternate path in vbus_draw callback")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/dwc3/gadget.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 858fe4c299b7..b3470a5e5e26 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -3049,8 +3049,11 @@  static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)
 	if (dwc->usb2_phy)
 		return usb_phy_set_power(dwc->usb2_phy, mA);
 
-	if (!dwc->usb_psy)
-		return -EOPNOTSUPP;
+	if (!dwc->usb_psy) {
+		dwc3_populate_usb_psy(dwc);
+		if (!dwc->usb_psy)
+			return -EOPNOTSUPP;
+	}
 
 	val.intval = 1000 * mA;
 	ret = power_supply_set_property(dwc->usb_psy, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &val);