diff options
Diffstat (limited to 'drivers/usb/host/xhci-mtk.c')
-rw-r--r-- | drivers/usb/host/xhci-mtk.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 96a0ff0bb11e..b1045f534a4b 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -401,29 +401,14 @@ static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM, clks); } -static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk) +static int xhci_mtk_vregs_get(struct xhci_hcd_mtk *mtk) { - int ret; + struct regulator_bulk_data *supplies = mtk->supplies; - ret = regulator_enable(mtk->vbus); - if (ret) { - dev_err(mtk->dev, "failed to enable vbus\n"); - return ret; - } - - ret = regulator_enable(mtk->vusb33); - if (ret) { - dev_err(mtk->dev, "failed to enable vusb33\n"); - regulator_disable(mtk->vbus); - return ret; - } - return 0; -} + supplies[0].supply = "vbus"; + supplies[1].supply = "vusb33"; -static void xhci_mtk_ldos_disable(struct xhci_hcd_mtk *mtk) -{ - regulator_disable(mtk->vbus); - regulator_disable(mtk->vusb33); + return devm_regulator_bulk_get(mtk->dev, BULK_VREGS_NUM, supplies); } static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci) @@ -513,17 +498,10 @@ static int xhci_mtk_probe(struct platform_device *pdev) return -ENOMEM; mtk->dev = dev; - mtk->vbus = devm_regulator_get(dev, "vbus"); - if (IS_ERR(mtk->vbus)) { - dev_err(dev, "fail to get vbus\n"); - return PTR_ERR(mtk->vbus); - } - mtk->vusb33 = devm_regulator_get(dev, "vusb33"); - if (IS_ERR(mtk->vusb33)) { - dev_err(dev, "fail to get vusb33\n"); - return PTR_ERR(mtk->vusb33); - } + ret = xhci_mtk_vregs_get(mtk); + if (ret) + return dev_err_probe(dev, ret, "Failed to get regulators\n"); ret = xhci_mtk_clks_get(mtk); if (ret) @@ -564,7 +542,7 @@ static int xhci_mtk_probe(struct platform_device *pdev) pm_runtime_enable(dev); pm_runtime_get_sync(dev); - ret = xhci_mtk_ldos_enable(mtk); + ret = regulator_bulk_enable(BULK_VREGS_NUM, mtk->supplies); if (ret) goto disable_pm; @@ -673,7 +651,7 @@ disable_clk: clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); disable_ldos: - xhci_mtk_ldos_disable(mtk); + regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); disable_pm: pm_runtime_put_noidle(dev); @@ -701,7 +679,7 @@ static int xhci_mtk_remove(struct platform_device *pdev) usb_put_hcd(hcd); xhci_mtk_sch_exit(mtk); clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks); - xhci_mtk_ldos_disable(mtk); + regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies); pm_runtime_disable(dev); pm_runtime_put_noidle(dev); |