mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yige Jiang <yigejiang86@gmail.com>
To: linux-usb@vger.kernel.org
Cc: Yige Jiang <yigejiang86@gmail.com>, Bin Liu <b-liu@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] usb: musb: tusb6010: retain and unregister the generic PHY
Date: Thu,  5 Nov 2026 02:28:37 +0800	[thread overview]
Message-ID: <rc-review-20261103-35-b81ec08fb02e@gmail.com> (raw)

usb_phy_generic_register() returns the newly registered PHY platform
device, but tusb_probe() discards that pointer. The zero-initialized
glue->phy is later passed to usb_phy_generic_unregister(), leaving the
actual registered device behind.

Store the returned device in glue->phy and stop probe if registration
fails. If registering the MUSB child subsequently fails, unregister
the PHY before returning the error. Normal removal already unregisters
the MUSB child first and can now pass the saved PHY to its cleanup.

Fixes: 2f36ff6915c6 ("usb: phy: generic: allow multiples calls to usb_phy_generic_register()")
Assisted-by: LLM
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261102 (2637bdec0535).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y.
COMPILE_TEST=y.
Baseline and patched target objects built from this exact base.
No full kernel/module-link, hardware or runtime test was performed.
AI assistance: Codex (LLM) for ownership analysis, code and changelog.

The N800/N810 registration path remains in this base. The proposed
OMAP24xx removal affects its future use; please advise on the target tree.
https://lore.kernel.org/all/20260914140821.1805449-1-arnd@kernel.org/

 drivers/usb/musb/tusb6010.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 1d9571f24a56..a7e0c6fabca4 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -1245,7 +1245,9 @@ static int tusb_probe(struct platform_device *pdev)
 
 	pdata->platform_ops		= &tusb_ops;
 
-	usb_phy_generic_register();
+	glue->phy = usb_phy_generic_register();
+	if (IS_ERR(glue->phy))
+		return PTR_ERR(glue->phy);
 	platform_set_drvdata(pdev, glue);
 
 	memset(musb_resources, 0x00, sizeof(*musb_resources) *
@@ -1274,6 +1276,7 @@ static int tusb_probe(struct platform_device *pdev)
 	if (IS_ERR(musb)) {
 		ret = PTR_ERR(musb);
 		dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
+		usb_phy_generic_unregister(glue->phy);
 		return ret;
 	}
 

base-commit: 2637bdec0535a2044cd830eba9a79363651d9043

                 reply	other threads:[~2026-11-04 18:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=rc-review-20261103-35-b81ec08fb02e@gmail.com \
    --to=yigejiang86@gmail.com \
    --cc=b-liu@ti.com \
    --cc=gregkh@linuxfoundation.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

all inboxes | Powered by JetHome®