[PATCH 05/19] pmdomain: push have_genpd_providers check into __genpd_dev_pm_attach
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Jan 19 08:25:56 PST 2024
genpd_activate() makes power domains opt-in per platform by considering
power domain attachment a success until gepd_activate() is called the
first time. We currently do that in genpd_dev_pm_attach(), but a follow
up commit will introduce more callers for __genpd_dev_pm_attach, which
likewise should have the same behavior regarding genpd_activate().
Thus push the check into __genpd_dev_pm_attach().
No function change.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/base/power.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/base/power.c b/drivers/base/power.c
index 4ff7b055c825..cfee5e793037 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -299,6 +299,13 @@ static void genpd_remove_device(struct generic_pm_domain *genpd,
dev->pm_domain = NULL;
}
+static bool have_genpd_providers;
+
+void genpd_activate(void)
+{
+ have_genpd_providers = true;
+}
+
static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
unsigned int index, bool power_on)
{
@@ -306,6 +313,9 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
struct generic_pm_domain *pd;
int ret;
+ if (!have_genpd_providers)
+ return 0;
+
ret = of_parse_phandle_with_args(np, "power-domains",
"#power-domain-cells", index, &pd_args);
if (ret < 0)
@@ -336,13 +346,6 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
return ret ?: 1;
}
-static bool have_genpd_providers;
-
-void genpd_activate(void)
-{
- have_genpd_providers = true;
-}
-
/**
* genpd_dev_pm_attach - Attach a device to its PM domain using DT.
* @dev: Device to attach.
@@ -361,9 +364,6 @@ int genpd_dev_pm_attach(struct device *dev)
if (!dev->of_node)
return 0;
- if (!have_genpd_providers)
- return 0;
-
/*
* Devices with multiple PM domains must be attached separately, as we
* can only attach one PM domain per device.
--
2.39.2
More information about the barebox
mailing list