[PATCH] mfd: omap-usb-host: fix OF populate on driver rebind

Johan Hovold posted 1 patch 1 month, 2 weeks ago
drivers/mfd/omap-usb-host.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Johan Hovold 1 month, 2 weeks ago
Since commit c6e126de43e7 ("of: Keep track of populated platform
devices") child devices will not be created by of_platform_populate()
if the devices had previously been deregistered individually so that the
OF_POPULATED flag is still set in the corresponding OF nodes.

Switch to using of_platform_depopulate() instead of open coding so that
the child devices are created if the driver is rebound.

Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
Cc: stable@vger.kernel.org	# 3.16
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/mfd/omap-usb-host.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
index a77b6fc790f2..4d29a6e2ed87 100644
--- a/drivers/mfd/omap-usb-host.c
+++ b/drivers/mfd/omap-usb-host.c
@@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
 {
 	pm_runtime_disable(&pdev->dev);
 
-	/* remove children */
-	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
+	if (pdev->dev.of_node)
+		of_platform_depopulate(&pdev->dev);
+	else
+		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
 }
 
 static const struct dev_pm_ops usbhsomap_dev_pm_ops = {
-- 
2.51.2
Re: (subset) [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Lee Jones 2 weeks, 4 days ago
On Fri, 19 Dec 2025 12:07:14 +0100, Johan Hovold wrote:
> Since commit c6e126de43e7 ("of: Keep track of populated platform
> devices") child devices will not be created by of_platform_populate()
> if the devices had previously been deregistered individually so that the
> OF_POPULATED flag is still set in the corresponding OF nodes.
> 
> Switch to using of_platform_depopulate() instead of open coding so that
> the child devices are created if the driver is rebound.
> 
> [...]

Applied, thanks!

[1/1] mfd: omap-usb-host: fix OF populate on driver rebind
      commit: 74283e1c49dd2d56e83bca070c163c56375c057d

--
Lee Jones [李琼斯]

Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Lee Jones 4 weeks, 1 day ago
On Fri, 19 Dec 2025, Johan Hovold wrote:

> Since commit c6e126de43e7 ("of: Keep track of populated platform
> devices") child devices will not be created by of_platform_populate()
> if the devices had previously been deregistered individually so that the
> OF_POPULATED flag is still set in the corresponding OF nodes.
> 
> Switch to using of_platform_depopulate() instead of open coding so that
> the child devices are created if the driver is rebound.
> 
> Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> Cc: stable@vger.kernel.org	# 3.16
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/mfd/omap-usb-host.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index a77b6fc790f2..4d29a6e2ed87 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
>  {
>  	pm_runtime_disable(&pdev->dev);
>  
> -	/* remove children */
> -	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> +	if (pdev->dev.of_node)
> +		of_platform_depopulate(&pdev->dev);

devm_of_platform_populate()?

> +	else
> +		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);

What on earth is this driver even doing in MFD?

Nightmare - quick dig, bury it!

-- 
Lee Jones [李琼斯]
Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Johan Hovold 3 weeks, 4 days ago
On Fri, Jan 09, 2026 at 04:37:25PM +0000, Lee Jones wrote:
> On Fri, 19 Dec 2025, Johan Hovold wrote:
> 
> > Since commit c6e126de43e7 ("of: Keep track of populated platform
> > devices") child devices will not be created by of_platform_populate()
> > if the devices had previously been deregistered individually so that the
> > OF_POPULATED flag is still set in the corresponding OF nodes.
> > 
> > Switch to using of_platform_depopulate() instead of open coding so that
> > the child devices are created if the driver is rebound.
> > 
> > Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> > Cc: stable@vger.kernel.org	# 3.16
> > Signed-off-by: Johan Hovold <johan@kernel.org>

> > @@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
> >  {
> >  	pm_runtime_disable(&pdev->dev);
> >  
> > -	/* remove children */
> > -	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> > +	if (pdev->dev.of_node)
> > +		of_platform_depopulate(&pdev->dev);
> 
> devm_of_platform_populate()?

Looks like that would work here, but I prefer using explicit removal for
both the OF and non-OF for symmetry and readability reasons.

If you think that the non-OF support can be removed then a devres
conversion can be done as part of that change.

> > +	else
> > +		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);

Johan
Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Lee Jones 4 weeks, 1 day ago
On Fri, 09 Jan 2026, Lee Jones wrote:

> On Fri, 19 Dec 2025, Johan Hovold wrote:
> 
> > Since commit c6e126de43e7 ("of: Keep track of populated platform
> > devices") child devices will not be created by of_platform_populate()
> > if the devices had previously been deregistered individually so that the
> > OF_POPULATED flag is still set in the corresponding OF nodes.
> > 
> > Switch to using of_platform_depopulate() instead of open coding so that
> > the child devices are created if the driver is rebound.
> > 
> > Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> > Cc: stable@vger.kernel.org	# 3.16
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  drivers/mfd/omap-usb-host.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> > index a77b6fc790f2..4d29a6e2ed87 100644
> > --- a/drivers/mfd/omap-usb-host.c
> > +++ b/drivers/mfd/omap-usb-host.c
> > @@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
> >  {
> >  	pm_runtime_disable(&pdev->dev);
> >  
> > -	/* remove children */
> > -	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> > +	if (pdev->dev.of_node)
> > +		of_platform_depopulate(&pdev->dev);
> 
> devm_of_platform_populate()?
> 
> > +	else
> > +		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> 
> What on earth is this driver even doing in MFD?
> 
> Nightmare - quick dig, bury it!

Is the old platform method even supported anymore?

$ git grep \"usbhs_omap\""
drivers/mfd/omap-usb-host.c:#define USBHS_DRIVER_NAME   "usbhs_omap"

-- 
Lee Jones [李琼斯]
Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Andreas Kemnade 4 weeks, 1 day ago
On Fri, 9 Jan 2026 16:39:39 +0000
Lee Jones <lee@kernel.org> wrote:

> On Fri, 09 Jan 2026, Lee Jones wrote:
> 
> > On Fri, 19 Dec 2025, Johan Hovold wrote:
> >   
> > > Since commit c6e126de43e7 ("of: Keep track of populated platform
> > > devices") child devices will not be created by of_platform_populate()
> > > if the devices had previously been deregistered individually so that the
> > > OF_POPULATED flag is still set in the corresponding OF nodes.
> > > 
> > > Switch to using of_platform_depopulate() instead of open coding so that
> > > the child devices are created if the driver is rebound.
> > > 
> > > Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> > > Cc: stable@vger.kernel.org	# 3.16
> > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > ---
> > >  drivers/mfd/omap-usb-host.c | 6 ++++--
> > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> > > index a77b6fc790f2..4d29a6e2ed87 100644
> > > --- a/drivers/mfd/omap-usb-host.c
> > > +++ b/drivers/mfd/omap-usb-host.c
> > > @@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
> > >  {
> > >  	pm_runtime_disable(&pdev->dev);
> > >  
> > > -	/* remove children */
> > > -	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> > > +	if (pdev->dev.of_node)
> > > +		of_platform_depopulate(&pdev->dev);  
> > 
> > devm_of_platform_populate()?
> >   
> > > +	else
> > > +		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);  
> > 
> > What on earth is this driver even doing in MFD?
> > 
> > Nightmare - quick dig, bury it!  
> 
> Is the old platform method even supported anymore?
> 
> $ git grep \"usbhs_omap\""
> drivers/mfd/omap-usb-host.c:#define USBHS_DRIVER_NAME   "usbhs_omap"
> 
:~/linux/arch/arm/boot/dts/ti/omap$ grep ti,usbhs-host *.dtsi
omap3.dtsi:			compatible = "ti,usbhs-host";
omap4-l4.dtsi:				compatible = "ti,usbhs-host";
omap5-l4.dtsi:				compatible = "ti,usbhs-host";

So it is still in use.

Regards,
Andreas
Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Lee Jones 4 weeks, 1 day ago
On Fri, 09 Jan 2026, Andreas Kemnade wrote:

> On Fri, 9 Jan 2026 16:39:39 +0000
> Lee Jones <lee@kernel.org> wrote:
> 
> > On Fri, 09 Jan 2026, Lee Jones wrote:
> > 
> > > On Fri, 19 Dec 2025, Johan Hovold wrote:
> > >   
> > > > Since commit c6e126de43e7 ("of: Keep track of populated platform
> > > > devices") child devices will not be created by of_platform_populate()
> > > > if the devices had previously been deregistered individually so that the
> > > > OF_POPULATED flag is still set in the corresponding OF nodes.
> > > > 
> > > > Switch to using of_platform_depopulate() instead of open coding so that
> > > > the child devices are created if the driver is rebound.
> > > > 
> > > > Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> > > > Cc: stable@vger.kernel.org	# 3.16
> > > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > > ---
> > > >  drivers/mfd/omap-usb-host.c | 6 ++++--
> > > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> > > > index a77b6fc790f2..4d29a6e2ed87 100644
> > > > --- a/drivers/mfd/omap-usb-host.c
> > > > +++ b/drivers/mfd/omap-usb-host.c
> > > > @@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
> > > >  {
> > > >  	pm_runtime_disable(&pdev->dev);
> > > >  
> > > > -	/* remove children */
> > > > -	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> > > > +	if (pdev->dev.of_node)
> > > > +		of_platform_depopulate(&pdev->dev);  
> > > 
> > > devm_of_platform_populate()?
> > >   
> > > > +	else
> > > > +		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);  
> > > 
> > > What on earth is this driver even doing in MFD?
> > > 
> > > Nightmare - quick dig, bury it!  
> > 
> > Is the old platform method even supported anymore?
> > 
> > $ git grep \"usbhs_omap\""
> > drivers/mfd/omap-usb-host.c:#define USBHS_DRIVER_NAME   "usbhs_omap"
> > 
> :~/linux/arch/arm/boot/dts/ti/omap$ grep ti,usbhs-host *.dtsi
> omap3.dtsi:			compatible = "ti,usbhs-host";
> omap4-l4.dtsi:				compatible = "ti,usbhs-host";
> omap5-l4.dtsi:				compatible = "ti,usbhs-host";

That's the new "DT" method.

What about the old "usbhs_omap" one?

Looks to me like support was removed by Tony in 2016:

  9080b8dc761a ("ARM: OMAP2+: Remove legacy usb-host.c platform init code")

-- 
Lee Jones [李琼斯]
Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Andreas Kemnade 4 weeks, 1 day ago
On Fri, 9 Jan 2026 18:18:39 +0100
Andreas Kemnade <andreas@kemnade.info> wrote:

> On Fri, 9 Jan 2026 16:39:39 +0000
> Lee Jones <lee@kernel.org> wrote:
> 
> > On Fri, 09 Jan 2026, Lee Jones wrote:
> >   
> > > On Fri, 19 Dec 2025, Johan Hovold wrote:
> > >     
> > > > Since commit c6e126de43e7 ("of: Keep track of populated platform
> > > > devices") child devices will not be created by of_platform_populate()
> > > > if the devices had previously been deregistered individually so that the
> > > > OF_POPULATED flag is still set in the corresponding OF nodes.
> > > > 
> > > > Switch to using of_platform_depopulate() instead of open coding so that
> > > > the child devices are created if the driver is rebound.
> > > > 
> > > > Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> > > > Cc: stable@vger.kernel.org	# 3.16
> > > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > > ---
> > > >  drivers/mfd/omap-usb-host.c | 6 ++++--
> > > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> > > > index a77b6fc790f2..4d29a6e2ed87 100644
> > > > --- a/drivers/mfd/omap-usb-host.c
> > > > +++ b/drivers/mfd/omap-usb-host.c
> > > > @@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
> > > >  {
> > > >  	pm_runtime_disable(&pdev->dev);
> > > >  
> > > > -	/* remove children */
> > > > -	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> > > > +	if (pdev->dev.of_node)
> > > > +		of_platform_depopulate(&pdev->dev);    
> > > 
> > > devm_of_platform_populate()?
> > >     
> > > > +	else
> > > > +		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);    
> > > 
> > > What on earth is this driver even doing in MFD?
> > > 
> > > Nightmare - quick dig, bury it!    
> > 
> > Is the old platform method even supported anymore?
> > 
> > $ git grep \"usbhs_omap\""
> > drivers/mfd/omap-usb-host.c:#define USBHS_DRIVER_NAME   "usbhs_omap"
> >   
> :~/linux/arch/arm/boot/dts/ti/omap$ grep ti,usbhs-host *.dtsi
> omap3.dtsi:			compatible = "ti,usbhs-host";
> omap4-l4.dtsi:				compatible = "ti,usbhs-host";
> omap5-l4.dtsi:				compatible = "ti,usbhs-host";
> 
> So it is still in use.
> 
ok, that was just answering in panic mode to prevent removal of a needed
driver. Reading it again: I think omap2/3/4/5 without devicetree will not work
anyway, so we can remove anything done on !dev->of_node.

Regards,
Andreas
Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Lee Jones 4 weeks, 1 day ago
On Fri, 09 Jan 2026, Andreas Kemnade wrote:

> On Fri, 9 Jan 2026 18:18:39 +0100
> Andreas Kemnade <andreas@kemnade.info> wrote:
> 
> > On Fri, 9 Jan 2026 16:39:39 +0000
> > Lee Jones <lee@kernel.org> wrote:
> > 
> > > On Fri, 09 Jan 2026, Lee Jones wrote:
> > >   
> > > > On Fri, 19 Dec 2025, Johan Hovold wrote:
> > > >     
> > > > > Since commit c6e126de43e7 ("of: Keep track of populated platform
> > > > > devices") child devices will not be created by of_platform_populate()
> > > > > if the devices had previously been deregistered individually so that the
> > > > > OF_POPULATED flag is still set in the corresponding OF nodes.
> > > > > 
> > > > > Switch to using of_platform_depopulate() instead of open coding so that
> > > > > the child devices are created if the driver is rebound.
> > > > > 
> > > > > Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> > > > > Cc: stable@vger.kernel.org	# 3.16
> > > > > Signed-off-by: Johan Hovold <johan@kernel.org>
> > > > > ---
> > > > >  drivers/mfd/omap-usb-host.c | 6 ++++--
> > > > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> > > > > index a77b6fc790f2..4d29a6e2ed87 100644
> > > > > --- a/drivers/mfd/omap-usb-host.c
> > > > > +++ b/drivers/mfd/omap-usb-host.c
> > > > > @@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev)
> > > > >  {
> > > > >  	pm_runtime_disable(&pdev->dev);
> > > > >  
> > > > > -	/* remove children */
> > > > > -	device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> > > > > +	if (pdev->dev.of_node)
> > > > > +		of_platform_depopulate(&pdev->dev);    
> > > > 
> > > > devm_of_platform_populate()?
> > > >     
> > > > > +	else
> > > > > +		device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);    
> > > > 
> > > > What on earth is this driver even doing in MFD?
> > > > 
> > > > Nightmare - quick dig, bury it!    
> > > 
> > > Is the old platform method even supported anymore?
> > > 
> > > $ git grep \"usbhs_omap\""
> > > drivers/mfd/omap-usb-host.c:#define USBHS_DRIVER_NAME   "usbhs_omap"
> > >   
> > :~/linux/arch/arm/boot/dts/ti/omap$ grep ti,usbhs-host *.dtsi
> > omap3.dtsi:			compatible = "ti,usbhs-host";
> > omap4-l4.dtsi:				compatible = "ti,usbhs-host";
> > omap5-l4.dtsi:				compatible = "ti,usbhs-host";
> > 
> > So it is still in use.
> > 
> ok, that was just answering in panic mode to prevent removal of a needed
> driver. Reading it again: I think omap2/3/4/5 without devicetree will not work
> anyway, so we can remove anything done on !dev->of_node.

Okay, leave it with me.

-- 
Lee Jones [李琼斯]
Re: [PATCH] mfd: omap-usb-host: fix OF populate on driver rebind
Posted by Andreas Kemnade 1 month, 1 week ago
On Fri, 19 Dec 2025 12:07:14 +0100
Johan Hovold <johan@kernel.org> wrote:

> Since commit c6e126de43e7 ("of: Keep track of populated platform
> devices") child devices will not be created by of_platform_populate()
> if the devices had previously been deregistered individually so that the
> OF_POPULATED flag is still set in the corresponding OF nodes.
> 
> Switch to using of_platform_depopulate() instead of open coding so that
> the child devices are created if the driver is rebound.
> 
> Fixes: c6e126de43e7 ("of: Keep track of populated platform devices")
> Cc: stable@vger.kernel.org	# 3.16
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Andreas Kemnade <andreas@kemnade.info>