Skip to contentSkip to conversation

usb: musb: tusb6010: retain and unregister the generic PHY

PATCH New Yige Jiang 2 participants 2 messages Nov 4

Subsystems (2)
lore
Share & tools
lore

Yige Jiang

author
#0 lore raw

PATCH 1/1 usb: musb: tusb6010: retain and unregister the generic PHY

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

---
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/[email protected]/

 drivers/usb/musb/tusb6010.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/musb/tusb6010.c +4 -1
index 1d9571f24a56..a7e0c6fabca4 100644
@@ -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

#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

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.

Quoted 8 lines

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

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1