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

Alexander Stein alexander.stein at ew.tq-group.com
Tue Feb 20 03:19:48 PST 2024


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

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

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);
-- 
2.34.1




More information about the linux-arm-kernel mailing list