diff mbox series

[1/1] phy: fsl-imx8mq-usb: make vbus regulator optional

Message ID 20240220111948.2227506-1-alexander.stein@ew.tq-group.com
State Changes Requested
Headers show
Series [1/1] phy: fsl-imx8mq-usb: make vbus regulator optional | expand

Commit Message

Alexander Stein Feb. 20, 2024, 11:19 a.m. UTC
vbus-supply property is optional, so instead of allocating a
dummy regulator make it pure optional.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Mark Brown Feb. 20, 2024, 1:49 p.m. UTC | #1
On Tue, Feb 20, 2024 at 12:19:48PM +0100, Alexander Stein wrote:

> vbus-supply property is optional, so instead of allocating a
> dummy regulator make it pure optional.

In general supplies should not be optional unless they may reasonably be
physically absent which is highly unusual.
diff mbox series

Patch

diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index 0b9a59d5b8f02..3af007b8e77f5 100644
--- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
@@ -323,9 +323,11 @@  static int imx8mq_phy_power_on(struct phy *phy)
 	struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy);
 	int ret;
 
-	ret = regulator_enable(imx_phy->vbus);
-	if (ret)
-		return ret;
+	if (imx_phy->vbus) {
+		ret = regulator_enable(imx_phy->vbus);
+		if (ret)
+			return ret;
+	}
 
 	return clk_prepare_enable(imx_phy->clk);
 }
@@ -335,7 +337,8 @@  static int imx8mq_phy_power_off(struct phy *phy)
 	struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy);
 
 	clk_disable_unprepare(imx_phy->clk);
-	regulator_disable(imx_phy->vbus);
+	if (imx_phy->vbus)
+		regulator_disable(imx_phy->vbus);
 
 	return 0;
 }
@@ -392,8 +395,10 @@  static int imx8mq_usb_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(imx_phy->phy))
 		return PTR_ERR(imx_phy->phy);
 
-	imx_phy->vbus = devm_regulator_get(dev, "vbus");
-	if (IS_ERR(imx_phy->vbus))
+	imx_phy->vbus = devm_regulator_get_optional(dev, "vbus");
+	if (PTR_ERR(imx_phy->vbus) == -ENODEV)
+		imx_phy->vbus = NULL;
+	else if (IS_ERR(imx_phy->vbus))
 		return dev_err_probe(dev, PTR_ERR(imx_phy->vbus), "failed to get vbus\n");
 
 	phy_set_drvdata(imx_phy->phy, imx_phy);