usb: phy: tegra: Disable VBUS regulator on tegra_usb_phy_init failure
authorDmitry Osipenko <digetx@gmail.com>
Mon, 6 Jan 2020 01:34:10 +0000 (04:34 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2020 15:21:58 +0000 (16:21 +0100)
VBUS regulator should be turned off in a case of error.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20200106013416.9604-15-digetx@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/phy/phy-tegra-usb.c

index c431968..90b42e9 100644 (file)
@@ -864,20 +864,20 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy)
                dev_err(phy->u_phy.dev, "Invalid pll_u parent rate %ld\n",
                        parent_rate);
                err = -EINVAL;
-               goto fail;
+               goto disable_clk;
        }
 
        err = regulator_enable(phy->vbus);
        if (err) {
                dev_err(phy->u_phy.dev,
                        "Failed to enable USB VBUS regulator: %d\n", err);
-               goto fail;
+               goto disable_clk;
        }
 
        if (!phy->is_ulpi_phy) {
                err = utmip_pad_open(phy);
                if (err)
-                       goto fail;
+                       goto disable_vbus;
        }
 
        err = tegra_usb_phy_power_on(phy);
@@ -889,7 +889,11 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy)
 close_phy:
        if (!phy->is_ulpi_phy)
                utmip_pad_close(phy);
-fail:
+
+disable_vbus:
+       regulator_disable(phy->vbus);
+
+disable_clk:
        clk_disable_unprepare(phy->pll_u);
 
        phy->freq = NULL;