mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Felix Gu <ustc.gu@gmail.com>
Cc: Conor Dooley <conor.dooley@microchip.com>,
	Daire McNamara <daire.mcnamara@microchip.com>,
	Bin Liu <b-liu@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-riscv@lists.infradead.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: musb: mpfs: tidy up error handling in probe()
Date: Tue, 15 Sep 2026 19:21:19 +0100	[thread overview]
Message-ID: <20260915-grouped-raffle-16b1fea4ad5f@spud> (raw)
In-Reply-To: <20260915-mpfs-1-v1-1-a12c2fd7e0d9@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2623 bytes --]

On Tue, Sep 15, 2026 at 01:14:08AM +0800, Felix Gu wrote:
> Restructure the probe error labels so each failure only tears down
> what was already acquired, and stop calling
> usb_phy_generic_unregister() with NULL or an ERR_PTR() on paths
> where the phy was never registered.
> 
> The old error paths only worked because platform_device_del() and
> platform_device_put() ignore NULL and ERR_PTR() arguments.
> 
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
>  drivers/usb/musb/mpfs.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/musb/mpfs.c b/drivers/usb/musb/mpfs.c
> index 587127abd30a..59625ed95656 100644
> --- a/drivers/usb/musb/mpfs.c
> +++ b/drivers/usb/musb/mpfs.c
> @@ -276,13 +276,13 @@ static int mpfs_probe(struct platform_device *pdev)
>  	if (IS_ERR(clk)) {
>  		dev_err(&pdev->dev, "failed to get clock\n");

Could go a step further if you want, and use devm_clk_get_enabled().

This is clearly the wrong order, so this patch is fine as-is.
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.

>  		ret = PTR_ERR(clk);
> -		goto err_phy_release;
> +		goto err_pdev_put;
>  	}
>  
>  	ret = clk_prepare_enable(clk);
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to enable clock\n");
> -		goto err_phy_release;
> +		goto err_pdev_put;
>  	}
>  
>  	musb_pdev->dev.parent = dev;
> @@ -324,29 +324,29 @@ static int mpfs_probe(struct platform_device *pdev)
>  	ret = platform_device_add_resources(musb_pdev, pdev->resource, pdev->num_resources);
>  	if (ret) {
>  		dev_err(dev, "failed to add resources\n");
> -		goto err_clk_disable;
> +		goto err_phy_release;
>  	}
>  
>  	ret = platform_device_add_data(musb_pdev, pdata, sizeof(*pdata));
>  	if (ret) {
>  		dev_err(dev, "failed to add platform_data\n");
> -		goto err_clk_disable;
> +		goto err_phy_release;
>  	}
>  
>  	ret = platform_device_add(musb_pdev);
>  	if (ret) {
>  		dev_err(dev, "failed to register musb device\n");
> -		goto err_clk_disable;
> +		goto err_phy_release;
>  	}
>  
>  	dev_info(&pdev->dev, "Registered MPFS MUSB driver\n");
>  	return 0;
>  
> -err_clk_disable:
> -	clk_disable_unprepare(clk);
> -
>  err_phy_release:
>  	usb_phy_generic_unregister(glue->phy);
> +err_clk_disable:
> +	clk_disable_unprepare(clk);
> +err_pdev_put:
>  	platform_device_put(musb_pdev);
>  	return ret;
>  }
> 
> ---
> base-commit: 68142f986ff04b2b70b31db00f719bf690f64a9a
> change-id: 20260914-mpfs-1-2e062f29128e
> 
> Best regards,
> --  
> Felix Gu <ustc.gu@gmail.com>
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2026-09-15 18:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 17:14 Felix Gu
2026-09-15 18:21 ` Conor Dooley [this message]

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=20260915-grouped-raffle-16b1fea4ad5f@spud \
    --to=conor@kernel.org \
    --cc=b-liu@ti.com \
    --cc=conor.dooley@microchip.com \
    --cc=daire.mcnamara@microchip.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ustc.gu@gmail.com \
    /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

all inboxes | Powered by JetHome®