Skip to content

Commit

Permalink
cpuidle: dt_idle_genpd: Add helper function to remove genpd topology
Browse files Browse the repository at this point in the history
commit 9a8fa00 upstream.

Genpd parent and child domain topology created using dt_idle_pd_init_topology()
needs to be removed during error cases.

Add new helper function dt_idle_pd_remove_topology() for same.

Cc: stable@vger.kernel.org
Reviewed-by: Ulf Hanssson <ulf.hansson@linaro.org>
Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
quic-maulik authored and gregkh committed Aug 16, 2023
1 parent 3d3fd58 commit 088773a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
24 changes: 24 additions & 0 deletions drivers/cpuidle/dt_idle_genpd.c
Expand Up @@ -152,6 +152,30 @@ int dt_idle_pd_init_topology(struct device_node *np)
return 0;
}

int dt_idle_pd_remove_topology(struct device_node *np)
{
struct device_node *node;
struct of_phandle_args child, parent;
int ret;

for_each_child_of_node(np, node) {
if (of_parse_phandle_with_args(node, "power-domains",
"#power-domain-cells", 0, &parent))
continue;

child.np = node;
child.args_count = 0;
ret = of_genpd_remove_subdomain(&parent, &child);
of_node_put(parent.np);
if (ret) {
of_node_put(node);
return ret;
}
}

return 0;
}

struct device *dt_idle_attach_cpu(int cpu, const char *name)
{
struct device *dev;
Expand Down
7 changes: 7 additions & 0 deletions drivers/cpuidle/dt_idle_genpd.h
Expand Up @@ -14,6 +14,8 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,

int dt_idle_pd_init_topology(struct device_node *np);

int dt_idle_pd_remove_topology(struct device_node *np);

struct device *dt_idle_attach_cpu(int cpu, const char *name);

void dt_idle_detach_cpu(struct device *dev);
Expand All @@ -36,6 +38,11 @@ static inline int dt_idle_pd_init_topology(struct device_node *np)
return 0;
}

static inline int dt_idle_pd_remove_topology(struct device_node *np)
{
return 0;
}

static inline struct device *dt_idle_attach_cpu(int cpu, const char *name)
{
return NULL;
Expand Down

0 comments on commit 088773a

Please sign in to comment.