USB: dwc3: clean up core init error handling
authorJohan Hovold <johan+linaro@kernel.org>
Tue, 4 Apr 2023 07:25:21 +0000 (09:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Apr 2023 08:18:22 +0000 (10:18 +0200)
Clean up the core init error handling by using descriptive names for the
error labels and releasing resourcing in reverse order consistently.

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20230404072524.19014-9-johan+linaro@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/core.c

index c2326a3..a83e9fc 100644 (file)
@@ -1018,7 +1018,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
        ret = dwc3_phy_setup(dwc);
        if (ret)
-               goto err0;
+               return ret;
 
        if (!dwc->ulpi_ready) {
                ret = dwc3_core_ulpi_init(dwc);
@@ -1027,7 +1027,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
                                dwc3_core_soft_reset(dwc);
                                ret = -EPROBE_DEFER;
                        }
-                       goto err0;
+                       return ret;
                }
                dwc->ulpi_ready = true;
        }
@@ -1035,7 +1035,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
        if (!dwc->phys_ready) {
                ret = dwc3_core_get_phy(dwc);
                if (ret)
-                       goto err0a;
+                       goto err_exit_ulpi;
                dwc->phys_ready = true;
        }
 
@@ -1052,7 +1052,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
        ret = dwc3_core_soft_reset(dwc);
        if (ret)
-               goto err1;
+               goto err_exit_usb3_phy;
 
        if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD &&
            !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) {
@@ -1087,16 +1087,16 @@ static int dwc3_core_init(struct dwc3 *dwc)
        usb_phy_set_suspend(dwc->usb3_phy, 0);
        ret = phy_power_on(dwc->usb2_generic_phy);
        if (ret < 0)
-               goto err2;
+               goto err_suspend_usb3_phy;
 
        ret = phy_power_on(dwc->usb3_generic_phy);
        if (ret < 0)
-               goto err3;
+               goto err_power_off_usb2_phy;
 
        ret = dwc3_event_buffers_setup(dwc);
        if (ret) {
                dev_err(dwc->dev, "failed to setup event buffers\n");
-               goto err4;
+               goto err_power_off_usb3_phy;
        }
 
        /*
@@ -1213,27 +1213,23 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
        return 0;
 
-err4:
+err_power_off_usb3_phy:
        phy_power_off(dwc->usb3_generic_phy);
-
-err3:
+err_power_off_usb2_phy:
        phy_power_off(dwc->usb2_generic_phy);
-
-err2:
-       usb_phy_set_suspend(dwc->usb2_phy, 1);
+err_suspend_usb3_phy:
        usb_phy_set_suspend(dwc->usb3_phy, 1);
-
-err1:
+       usb_phy_set_suspend(dwc->usb2_phy, 1);
+err_exit_usb3_phy:
        phy_exit(dwc->usb3_generic_phy);
 err_exit_usb2_phy:
        phy_exit(dwc->usb2_generic_phy);
 err_shutdown_usb3_phy:
        usb_phy_shutdown(dwc->usb3_phy);
        usb_phy_shutdown(dwc->usb2_phy);
-err0a:
+err_exit_ulpi:
        dwc3_ulpi_exit(dwc);
 
-err0:
        return ret;
 }