From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Johan Hovold <johan+linaro@kernel.org>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 08/11] USB: dwc3: clean up core init error handling
Date: Fri, 7 Apr 2023 00:56:27 +0000 [thread overview]
Message-ID: <20230407005613.dbbfezhy3e6rqbvf@synopsys.com> (raw)
In-Reply-To: <20230404072524.19014-9-johan+linaro@kernel.org>
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@kernel.org>
> ---
> 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@synopsys.com>
Thanks,
Thinh
next prev parent reply other threads:[~2023-04-07 0:56 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 7:25 [PATCH 00/11] USB: dwc3: error handling fixes and cleanups Johan Hovold
2023-04-04 7:25 ` [PATCH 01/11] USB: dwc3: fix runtime pm imbalance on probe errors Johan Hovold
2023-04-11 1:22 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 02/11] USB: dwc3: fix runtime pm imbalance on unbind Johan Hovold
2023-04-11 1:22 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 03/11] USB: dwc3: disable autosuspend " Johan Hovold
2023-04-11 1:17 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 04/11] USB: dwc3: gadget: drop dead hibernation code Johan Hovold
2023-04-07 1:59 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 05/11] USB: dwc3: " Johan Hovold
2023-04-07 1:58 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 06/11] USB: dwc3: clean up probe error labels Johan Hovold
2023-04-07 0:49 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 07/11] USB: dwc3: clean up phy init error handling Johan Hovold
2023-04-07 1:00 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 08/11] USB: dwc3: clean up core " Johan Hovold
2023-04-07 0:56 ` Thinh Nguyen [this message]
2023-04-04 7:25 ` [PATCH 09/11] USB: dwc3: refactor phy handling Johan Hovold
2023-04-07 1:31 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 10/11] USB: dwc3: refactor clock lookups Johan Hovold
2023-04-07 0:47 ` Thinh Nguyen
2023-04-04 7:25 ` [PATCH 11/11] USB: dwc3: clean up probe declarations Johan Hovold
2023-04-07 0:46 ` Thinh Nguyen
2023-04-07 2:09 ` [PATCH 00/11] USB: dwc3: error handling fixes and cleanups Thinh Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230407005613.dbbfezhy3e6rqbvf@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan+linaro@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).