[PATCH v13 03/14] usb: chipidea: imx: add return value check for devm_regulator_get

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- If devm_regulator_get returns -EPROBE_DEFER, we also return
-EPROBE_DEFER to wait regulator being ready later.
- If devm_regulator_get returns -ENODEV, we think there is
no "vbus-supply" node at DT, it means this board doesn't need
vbus control.
- If devm_regulator_get returns other error values, it means
there are something wrong for getting this regulator.

Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>
---
 drivers/usb/chipidea/ci_hdrc_imx.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index d06355e..0ced8c1 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -144,8 +144,18 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 
 	/* Get the vbus regulator */
 	pdata.reg_vbus = devm_regulator_get(&pdev->dev, "vbus");
-	if (IS_ERR(pdata.reg_vbus))
-		pdata.reg_vbus = NULL;
+	if (PTR_ERR(pdata.reg_vbus) == -EPROBE_DEFER) {
+		ret = -EPROBE_DEFER;
+		goto err_clk;
+	} else if (PTR_ERR(pdata.reg_vbus) == -ENODEV) {
+		pdata.reg_vbus = NULL; /* no vbus regualator is needed */
+	} else if (IS_ERR(pdata.reg_vbus)) {
+		dev_err(&pdev->dev,
+				"Getting regulator error: %ld\n",
+					PTR_ERR(pdata.reg_vbus));
+		ret = PTR_ERR(pdata.reg_vbus);
+		goto err_clk;
+	}
 
 	if (!pdev->dev.dma_mask)
 		pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
-- 
1.7.0.4


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux