With the addition of commit 4aca68990d04 ("drivers: power: ignore power
domains with barebox,allow-dummy"), it's possible for genpd to be NULL
when there is no driver and the device tree node has barebox,allow-dummy
in it.

Allow for this possibility in genpd_add_device and genpd_remove_device
as well.

Fixes: 44c6bedbd439 ("pmdomain: allow callback for when devices are attached")
Signed-off-by: Ahmad Fatoum <[email protected]>
---
Issue is in master, but has not yet hit a release.
Needed also on next to fix CI breakage as the issue became visible only
after in-tree boards started using barebox,allow-dummy.
---
 drivers/base/power.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power.c b/drivers/base/power.c
index 668b835df3e6..c71389422a53 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -335,7 +335,7 @@ static int genpd_add_device(struct generic_pm_domain 
*genpd, struct device *dev)
 {
        dev->pm_domain = genpd;
 
-       if (genpd->attach_dev)
+       if (genpd && genpd->attach_dev)
                return genpd->attach_dev(genpd, dev);
 
        return 0;
@@ -344,7 +344,7 @@ static int genpd_add_device(struct generic_pm_domain 
*genpd, struct device *dev)
 static void genpd_remove_device(struct generic_pm_domain *genpd,
                               struct device *dev)
 {
-       if (genpd->detach_dev)
+       if (genpd && genpd->detach_dev)
                genpd->detach_dev(genpd, dev);
 
        dev->pm_domain = NULL;
-- 
2.47.3


Reply via email to