Re: [PATCH 08/11] USB: dwc3: clean up core init error handling

From: Thinh Nguyen
Date: Thu Apr 06 2023 - 20:56:48 EST


On Tue, Apr 04, 2023, Johan Hovold wrote:
> Clean up the core init error handling by using descriptive names for the
> error labels and releasing resourcing in reverse order consistently.
>
> Signed-off-by: Johan Hovold <johan+linaro@xxxxxxxxxx>
> ---
> drivers/usb/dwc3/core.c | 30 +++++++++++++-----------------
> 1 file changed, 13 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 15405f1f7aef..c499ef026500 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1008,7 +1008,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);
> @@ -1017,7 +1017,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;
> }
> @@ -1025,7 +1025,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;
> }
>
> @@ -1042,7 +1042,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)) {
> @@ -1077,16 +1077,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;
> }
>
> /*
> @@ -1203,27 +1203,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;
> }
>
> --
> 2.39.2
>

Acked-by: Thinh Nguyen <Thinh.Nguyen@xxxxxxxxxxxx>

Thanks,
Thinh