All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"michal.simek@amd.com" <michal.simek@amd.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"git@amd.com" <git@amd.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 3/3] usb: dwc3: xilinx: fix error handling in zynqmp init error paths
Date: Thu, 14 May 2026 01:43:07 +0000	[thread overview]
Message-ID: <agUnwgXyyrGQ2t2y@vbox> (raw)
In-Reply-To: <20260511160814.2904882-4-radhey.shyam.pandey@amd.com>

On Mon, May 11, 2026, Radhey Shyam Pandey wrote:
> Fix error handling and resource cleanup i.e remove invalid
> phy_exit() after failed phy_init(), route failures through
> proper cleanup paths and return 0 explicitly on success.
> 
> Fixes: 84770f028fab ("usb: dwc3: Add driver for Xilinx platforms")
> Cc: stable@vger.kernel.org
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> ---
>  drivers/usb/dwc3/dwc3-xilinx.c | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
> index 94458b3da1a0..b832505e1b04 100644
> --- a/drivers/usb/dwc3/dwc3-xilinx.c
> +++ b/drivers/usb/dwc3/dwc3-xilinx.c
> @@ -176,15 +176,13 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
>  	}
>  
>  	ret = phy_init(priv_data->usb3_phy);
> -	if (ret < 0) {
> -		phy_exit(priv_data->usb3_phy);
> +	if (ret < 0)
>  		goto err;
> -	}
>  
>  	ret = reset_control_deassert(apbrst);
>  	if (ret < 0) {
>  		dev_err(dev, "Failed to release APB reset\n");
> -		goto err;
> +		goto err_phy_exit;
>  	}
>  
>  	if (priv_data->usb3_phy) {
> @@ -200,26 +198,24 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
>  	ret = reset_control_deassert(crst);
>  	if (ret < 0) {
>  		dev_err(dev, "Failed to release core reset\n");
> -		goto err;
> +		goto err_phy_exit;
>  	}
>  
>  	ret = reset_control_deassert(hibrst);
>  	if (ret < 0) {
>  		dev_err(dev, "Failed to release hibernation reset\n");
> -		goto err;
> +		goto err_phy_exit;
>  	}
>  
>  	ret = phy_power_on(priv_data->usb3_phy);
> -	if (ret < 0) {
> -		phy_exit(priv_data->usb3_phy);
> -		goto err;
> -	}
> +	if (ret < 0)
> +		goto err_phy_exit;
>  
>  	/* ulpi reset via gpio-modepin or gpio-framework driver */
>  	reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
>  	if (IS_ERR(reset_gpio)) {
> -		return dev_err_probe(dev, PTR_ERR(reset_gpio),
> -				     "Failed to request reset GPIO\n");
> +		ret = PTR_ERR(reset_gpio);
> +		goto err_phy_power_off;
>  	}
>  
>  	if (reset_gpio) {
> @@ -229,6 +225,13 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
>  	}
>  
>  	dwc3_xlnx_set_coherency(priv_data, XLNX_USB_TRAFFIC_ROUTE_CONFIG);
> +
> +	return 0;
> +
> +err_phy_power_off:
> +	phy_power_off(priv_data->usb3_phy);
> +err_phy_exit:
> +	phy_exit(priv_data->usb3_phy);
>  err:
>  	return ret;
>  }
> -- 
> 2.44.4
> 

This fix should be a separate patch from this cleanup series.

Thanks,
Thinh

  reply	other threads:[~2026-05-14  1:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 16:08 [PATCH 0/3] usb: dwc3: xilinx: minor fixes for dwc3-xilinx glue driver Radhey Shyam Pandey
2026-05-11 16:08 ` [PATCH 1/3] usb: dwc3: xilinx: fix missing space before closing comment delimiter Radhey Shyam Pandey
2026-05-14  1:23   ` Thinh Nguyen
2026-05-11 16:08 ` [PATCH 2/3] usb: dwc3: xilinx: use reset_control_reset() in versal init Radhey Shyam Pandey
2026-05-14  1:34   ` Thinh Nguyen
2026-05-11 16:08 ` [PATCH 3/3] usb: dwc3: xilinx: fix error handling in zynqmp init error paths Radhey Shyam Pandey
2026-05-14  1:43   ` Thinh Nguyen [this message]
2026-05-14 12:52     ` Pandey, Radhey Shyam
2026-05-16  0:04       ` 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=agUnwgXyyrGQ2t2y@vbox \
    --to=thinh.nguyen@synopsys.com \
    --cc=git@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=p.zabel@pengutronix.de \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.