From: Ivan T. Ivanov iiva...@mm-sol.com
Move memory, regulators, clocks and irq allocation to
devm_* variants. Properly check for valid clk handles.
Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com
---
drivers/usb/phy/phy-msm-usb.c | 195 --
1 file changed, 75 insertions(+), 120 deletions(-)
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6bae936..67cac96 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int
init)
int ret = 0;
if (init) {
- motg-vddcx = regulator_get(motg-phy.dev, HSUSB_VDDCX);
- if (IS_ERR(motg-vddcx)) {
- dev_err(motg-phy.dev, unable to get hsusb vddcx\n);
- return PTR_ERR(motg-vddcx);
- }
-
ret = regulator_set_voltage(motg-vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg-phy.dev, unable to set the voltage
for hsusb vddcx\n);
- regulator_put(motg-vddcx);
return ret;
}
ret = regulator_enable(motg-vddcx);
- if (ret) {
+ if (ret)
dev_err(motg-phy.dev, unable to enable hsusb
vddcx\n);
- regulator_put(motg-vddcx);
- }
} else {
ret = regulator_set_voltage(motg-vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
@@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int
init)
ret = regulator_disable(motg-vddcx);
if (ret)
dev_err(motg-phy.dev, unable to disable hsusb
vddcx\n);
-
- regulator_put(motg-vddcx);
}
return ret;
@@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int
init)
int rc = 0;
if (init) {
- motg-v3p3 = regulator_get(motg-phy.dev, HSUSB_3p3);
- if (IS_ERR(motg-v3p3)) {
- dev_err(motg-phy.dev, unable to get hsusb 3p3\n);
- return PTR_ERR(motg-v3p3);
- }
-
rc = regulator_set_voltage(motg-v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg-phy.dev, unable to set voltage level
for hsusb 3p3\n);
- goto put_3p3;
+ goto exit;
}
rc = regulator_enable(motg-v3p3);
if (rc) {
dev_err(motg-phy.dev, unable to enable the hsusb
3p3\n);
- goto put_3p3;
- }
- motg-v1p8 = regulator_get(motg-phy.dev, HSUSB_1p8);
- if (IS_ERR(motg-v1p8)) {
- dev_err(motg-phy.dev, unable to get hsusb 1p8\n);
- rc = PTR_ERR(motg-v1p8);
- goto disable_3p3;
+ goto exit;
}
rc = regulator_set_voltage(motg-v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
dev_err(motg-phy.dev, unable to set voltage level
for hsusb 1p8\n);
- goto put_1p8;
+ goto disable_3p3;
}
rc = regulator_enable(motg-v1p8);
if (rc) {
dev_err(motg-phy.dev, unable to enable the hsusb
1p8\n);
- goto put_1p8;
+ goto disable_3p3;
}
return 0;
}
regulator_disable(motg-v1p8);
-put_1p8:
- regulator_put(motg-v1p8);
disable_3p3:
regulator_disable(motg-v3p3);
-put_3p3:
- regulator_put(motg-v3p3);
+exit:
return rc;
}
@@ -506,7 +480,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
clk_disable_unprepare(motg-pclk);
clk_disable_unprepare(motg-clk);
- if (motg-core_clk)
+ if (!IS_ERR(motg-core_clk))
clk_disable_unprepare(motg-core_clk);
if (!IS_ERR(motg-pclk_src))
@@ -546,7 +520,7 @@ static int msm_otg_resume(struct msm_otg *motg)
clk_prepare_enable(motg-pclk);
clk_prepare_enable(motg-clk);
- if (motg-core_clk)
+ if (!IS_ERR(motg-core_clk))
clk_prepare_enable(motg-core_clk);
if (motg-pdata-phy_type == SNPS_28NM_INTEGRATED_PHY
@@ -1415,37 +1389,34 @@ static int msm_otg_probe(struct platform_device *pdev)
return -ENODEV;
}
- motg =