[PATCH 05/11] pmdomain: core: Use device_set_node() to assign the fwnode too

Ulf Hansson
2025-04-17T14:25:41Z

Rather than just assigning the dev->of_node for the genpd's device, let's
use device_set_node() to make sure the fwnode gets assigned too. This is
needed to allow fw_devlink to work correctly, for example.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/pmdomain/core.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index da51a61a974c..3911d3e96626 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -2627,6 +2627,7 @@ static bool genpd_present(const struct generic_pm_domain *genpd)
int of_genpd_add_provider_simple(struct device_node *np,
struct generic_pm_domain *genpd)
{
+ struct fwnode_handle *fwnode;
int ret;

if (!np || !genpd)
@@ -2635,7 +2636,9 @@ int of_genpd_add_provider_simple(struct device_node *np,
if (!genpd_present(genpd))
return -EINVAL;

- genpd->dev.of_node = np;
+ fwnode = &np->fwnode;
+
+ device_set_node(&genpd->dev, fwnode);

/* Parse genpd OPP table */
if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
@@ -2661,7 +2664,7 @@ int of_genpd_add_provider_simple(struct device_node *np,
return ret;
}

- genpd->provider = &np->fwnode;
+ genpd->provider = fwnode;
genpd->has_provider = true;

return 0;
@@ -2677,6 +2680,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
struct genpd_onecell_data *data)
{
struct generic_pm_domain *genpd;
+ struct fwnode_handle *fwnode;
unsigned int i;
int ret = -EINVAL;

@@ -2686,6 +2690,8 @@ int of_genpd_add_provider_onecell(struct device_node *np,
if (!data->xlate)
data->xlate = genpd_xlate_onecell;

+ fwnode = &np->fwnode;
+
for (i = 0; i < data->num_domains; i++) {
genpd = data->domains[i];

@@ -2694,7 +2700,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
if (!genpd_present(genpd))
goto error;

- genpd->dev.of_node = np;
+ device_set_node(&genpd->dev, fwnode);

/* Parse genpd OPP table */
if (!genpd_is_opp_table_fw(genpd) && genpd->set_performance_state) {
@@ -2713,7 +2719,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
WARN_ON(IS_ERR(genpd->opp_table));
}

- genpd->provider = &np->fwnode;
+ genpd->provider = fwnode;
genpd->has_provider = true;
}

--
2.43.0