* [PATCH] usb: musb: da8xx: depopulate OF children on teardown
@ 2026-06-16 0:58 Pengpeng Hou
2026-07-10 13:03 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-16 0:58 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman, linux-usb, linux-kernel; +Cc: Pengpeng Hou
da8xx_probe() populates OF child devices before registering the MUSB
platform device. If population partially succeeds and then reports an
error, or if the later MUSB device registration fails, the already-created
OF children are left behind.
Depopulate the OF children on these probe failure paths and during remove
before unregistering the generic USB PHY, keeping the child-device
lifetime paired with the parent glue device.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
drivers/usb/musb/da8xx.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 4209f438ba18..af05c4bcb43c 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -562,7 +562,7 @@ static int da8xx_probe(struct platform_device *pdev)
ret = of_platform_populate(pdev->dev.of_node, NULL,
da8xx_auxdata_lookup, &pdev->dev);
if (ret)
- goto err_unregister_phy;
+ goto err_depopulate;
pinfo = da8xx_dev_info;
pinfo.parent = &pdev->dev;
@@ -577,11 +577,13 @@ static int da8xx_probe(struct platform_device *pdev)
ret = PTR_ERR_OR_ZERO(glue->musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
- goto err_unregister_phy;
+ goto err_depopulate;
}
return 0;
+err_depopulate:
+ of_platform_depopulate(&pdev->dev);
err_unregister_phy:
usb_phy_generic_unregister(glue->usb_phy);
return ret;
@@ -592,6 +594,7 @@ static void da8xx_remove(struct platform_device *pdev)
struct da8xx_glue *glue = platform_get_drvdata(pdev);
platform_device_unregister(glue->musb);
+ of_platform_depopulate(&pdev->dev);
usb_phy_generic_unregister(glue->usb_phy);
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: musb: da8xx: depopulate OF children on teardown
2026-06-16 0:58 [PATCH] usb: musb: da8xx: depopulate OF children on teardown Pengpeng Hou
@ 2026-07-10 13:03 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-10 13:03 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: Bin Liu, linux-usb, linux-kernel
On Tue, Jun 16, 2026 at 08:58:19AM +0800, Pengpeng Hou wrote:
> da8xx_probe() populates OF child devices before registering the MUSB
> platform device. If population partially succeeds and then reports an
> error, or if the later MUSB device registration fails, the already-created
> OF children are left behind.
>
> Depopulate the OF children on these probe failure paths and during remove
> before unregistering the generic USB PHY, keeping the child-device
> lifetime paired with the parent glue device.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> drivers/usb/musb/da8xx.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index 4209f438ba18..af05c4bcb43c 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -562,7 +562,7 @@ static int da8xx_probe(struct platform_device *pdev)
> ret = of_platform_populate(pdev->dev.of_node, NULL,
> da8xx_auxdata_lookup, &pdev->dev);
> if (ret)
> - goto err_unregister_phy;
> + goto err_depopulate;
>
> pinfo = da8xx_dev_info;
> pinfo.parent = &pdev->dev;
> @@ -577,11 +577,13 @@ static int da8xx_probe(struct platform_device *pdev)
> ret = PTR_ERR_OR_ZERO(glue->musb);
> if (ret) {
> dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
> - goto err_unregister_phy;
> + goto err_depopulate;
> }
>
> return 0;
>
> +err_depopulate:
> + of_platform_depopulate(&pdev->dev);
> err_unregister_phy:
> usb_phy_generic_unregister(glue->usb_phy);
> return ret;
> @@ -592,6 +594,7 @@ static void da8xx_remove(struct platform_device *pdev)
> struct da8xx_glue *glue = platform_get_drvdata(pdev);
>
> platform_device_unregister(glue->musb);
> + of_platform_depopulate(&pdev->dev);
> usb_phy_generic_unregister(glue->usb_phy);
> }
>
> --
> 2.50.1 (Apple Git-155)
>
This results in a build warning now, right?
Please fix.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-10 13:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-16 0:58 [PATCH] usb: musb: da8xx: depopulate OF children on teardown Pengpeng Hou
2026-07-10 13:03 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox