Commit d2f19782 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: dwc3: clean up core init error handling

Clean up the core init error handling by using descriptive names for the
error labels and releasing resourcing in reverse order consistently.
Acked-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20230404072524.19014-9-johan+linaro@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c8e9eccf
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment