diff options
author | Fabrice Gasnier <fabrice.gasnier@foss.st.com> | 2023-04-14 10:41:34 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-04-20 10:17:06 +0200 |
commit | 236d835302bd4e11697dfe65eb24a219ea5c70eb (patch) | |
tree | 6c538417c15bc5ba2db491457c802b6120fce3e0 /drivers/usb | |
parent | 6a14ffc05c60fb4d5b7beb95460ac5642293e03f (diff) | |
download | lwn-236d835302bd4e11697dfe65eb24a219ea5c70eb.tar.gz lwn-236d835302bd4e11697dfe65eb24a219ea5c70eb.zip |
usb: dwc2: improve error handling in __dwc2_lowlevel_hw_enable
Add error handling in __dwc2_lowlevel_hw_enable() that may leave the
clocks and regulators enabled upon error.
Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20230414084137.1050487-2-fabrice.gasnier@foss.st.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/dwc2/platform.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index d1589ba7d322..c431ce6c119f 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -104,7 +104,7 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) if (hsotg->clk) { ret = clk_prepare_enable(hsotg->clk); if (ret) - return ret; + goto err_dis_reg; } if (hsotg->uphy) { @@ -113,10 +113,25 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); } else { ret = phy_init(hsotg->phy); - if (ret == 0) + if (ret == 0) { ret = phy_power_on(hsotg->phy); + if (ret) + phy_exit(hsotg->phy); + } } + if (ret) + goto err_dis_clk; + + return 0; + +err_dis_clk: + if (hsotg->clk) + clk_disable_unprepare(hsotg->clk); + +err_dis_reg: + regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); + return ret; } |