[PATCH v3] usb: phy: generic: request the vbus supply only when it is described

Yang Siyuan posted 1 patch 3 days, 12 hours ago
drivers/usb/phy/phy-generic.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
[PATCH v3] usb: phy: generic: request the vbus supply only when it is described
Posted by Yang Siyuan 3 days, 12 hours ago
usb_phy_gen_create_phy() unconditionally asks for an exclusive "vbus"
regulator. The legacy usb_phy_generic platform device registered by USB
glue drivers (e.g. sunxi MUSB) has no firmware node, so the lookup ends
up in the dummy-regulator path and the regulator core warns:

  usb_phy_generic usb_phy_generic.1.auto: dummy supplies not allowed for
  exclusive requests (id=vbus)

Only issue the request when the device firmware actually describes a
vbus-supply, and keep treating -ENODEV as "not present".

Fixes: 03e607cbb293 ("usb: phy: generic: Get the vbus supply")
Tested-by: Freimut Diener <f.diener@pengutronix.de>
Signed-off-by: Yang Siyuan <hsyysy@163.com>
---
Changes in v3:
- Drop the blank line between the Fixes: tag and the trailer block, as
  requested by Greg Kroah-Hartman.
- Add the Tested-by tag from Freimut Diener (NXP i.MX93 FRDM board).

Changes in v2:
- Add the Fixes tag suggested by Sashiko.

 drivers/usb/phy/phy-generic.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index de26b3023..24b7ba536 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -238,7 +238,17 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
 		return dev_err_probe(dev, PTR_ERR(nop->vcc),
 				     "could not get vcc regulator\n");
 
-	nop->vbus_draw = devm_regulator_get_exclusive(dev, "vbus");
+	/*
+	 * vbus is an optional supply that only exists when the firmware
+	 * describes it. The legacy usb_phy_generic devices registered by USB
+	 * glue drivers have no firmware node, and requesting an exclusive
+	 * dummy supply only makes the regulator core warn.
+	 */
+	if (device_property_present(dev, "vbus-supply"))
+		nop->vbus_draw = devm_regulator_get_exclusive(dev, "vbus");
+	else
+		nop->vbus_draw = NULL;
+
 	if (PTR_ERR(nop->vbus_draw) == -ENODEV)
 		nop->vbus_draw = NULL;
 	if (IS_ERR(nop->vbus_draw))
base-commit: 091b06388b117fefdcb63336ac09956a4914b961
-- 
2.56.0