Re: [PATCH] mfd: qcom-pm8xxx: fix OF populate on driver rebind

From: Johan Hovold

Date: Tue Jan 13 2026 - 04:24:30 EST


On Fri, Jan 09, 2026 at 03:27:38PM +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@xxxxxxxxxxxxxxx # 3.16
> > Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>

> > -static int pm8xxx_remove_child(struct device *dev, void *unused)
> > -{
> > - platform_device_unregister(to_platform_device(dev));
> > - return 0;
> > -}
> > -
> > static void pm8xxx_remove(struct platform_device *pdev)
> > {
> > struct pm_irq_chip *chip = platform_get_drvdata(pdev);
> >
> > - device_for_each_child(&pdev->dev, NULL, pm8xxx_remove_child);
> > + of_platform_depopulate(&pdev->dev);
> > irq_domain_remove(chip->irqdomain);
>
> Have you explored devm_of_platform_populate()?

Yeah, but mixing devres and explicit release risks introducing bugs. And
here we want to make sure the children are deregistered before freeing
the irqdomain.

Johan