Skip to contentSkip to conversation

mfd: qcom-pm8xxx: fix OF populate on driver rebind

PATCH Applied Johan Hovold 4 participants 6 messages Dec 19, 2025 – Jan 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: qcom-pm8xxx: fix OF populate on driver rebind

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")
---
 drivers/mfd/qcom-pm8xxx.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/mfd/qcom-pm8xxx.c +1 -7
index 1149f7102a36..0cf374c015ce 100644
@@ -577,17 +577,11 @@ static int pm8xxx_probe(struct platform_device *pdev)
 	return rc;
 }
 
-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);
 }
 
Signature · 1 line
2.51.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Johan Hovold

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.

Quoted 7 lines

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")

---

Konrad

Reviewed-by on v1 1/1
#2 lore raw
In reply to Johan Hovold
Quoted 8 lines · Johan Hovold

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.

Quoted 7 lines
Fixes c6e126de43e7 ("of: Keep track of populated platform devices")
---
 drivers/mfd/qcom-pm8xxx.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
Signature · 2 lines
With best wishes
Dmitry
maintainer
#3 lore raw
In reply to Johan Hovold
Quoted 26 lines · Johan Hovold

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")
---
 drivers/mfd/qcom-pm8xxx.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/mfd/qcom-pm8xxx.c +0 -3
index 1149f7102a36..0cf374c015ce 100644
@@ -577,17 +577,11 @@ static int pm8xxx_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static int pm8xxx_remove_child(struct device *dev, void *unused)
-{
-	platform_device_unregister(to_platform_device(dev));

drivers/mfd/qcom-pm8xxx.c static int pm8xxx_probe(struct platform_device *pdev) · line 585

Quoted 10 lines
drivers/mfd/qcom-pm8xxx.c +1 -4
-	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()?

Signature · 1 line
Lee Jones [李琼斯]
#4 lore raw
Quoted 24 lines · Lee Jones
Quoted 22 lines · Johan Hovold

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")
drivers/mfd/qcom-pm8xxx.c +0 -6
-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);
Quoted 5 lines

drivers/mfd/qcom-pm8xxx.c static int pm8xxx_probe(struct platform_device *pdev) · line 585

Quoted 3 lines
drivers/mfd/qcom-pm8xxx.c +1 -1
-	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

maintainer Applied
#5 lore raw

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

In reply to Johan Hovold
Quoted 9 lines · Johan Hovold

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: qcom-pm8xxx: fix OF populate on driver rebind

      commit: 0b6a34ca0ac3b6e02389a2594f0638e5b9c65814

--
Lee Jones [李琼斯]