Skip to content

Commit 9a8fa00

Browse files
maulik-k-shahstorulf
authored andcommitted
cpuidle: dt_idle_genpd: Add helper function to remove genpd topology
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>
1 parent 52a93d3 commit 9a8fa00

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

drivers/cpuidle/dt_idle_genpd.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,30 @@ int dt_idle_pd_init_topology(struct device_node *np)
152152
return 0;
153153
}
154154

155+
int dt_idle_pd_remove_topology(struct device_node *np)
156+
{
157+
struct device_node *node;
158+
struct of_phandle_args child, parent;
159+
int ret;
160+
161+
for_each_child_of_node(np, node) {
162+
if (of_parse_phandle_with_args(node, "power-domains",
163+
"#power-domain-cells", 0, &parent))
164+
continue;
165+
166+
child.np = node;
167+
child.args_count = 0;
168+
ret = of_genpd_remove_subdomain(&parent, &child);
169+
of_node_put(parent.np);
170+
if (ret) {
171+
of_node_put(node);
172+
return ret;
173+
}
174+
}
175+
176+
return 0;
177+
}
178+
155179
struct device *dt_idle_attach_cpu(int cpu, const char *name)
156180
{
157181
struct device *dev;

drivers/cpuidle/dt_idle_genpd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
1414

1515
int dt_idle_pd_init_topology(struct device_node *np);
1616

17+
int dt_idle_pd_remove_topology(struct device_node *np);
18+
1719
struct device *dt_idle_attach_cpu(int cpu, const char *name);
1820

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

41+
static inline int dt_idle_pd_remove_topology(struct device_node *np)
42+
{
43+
return 0;
44+
}
45+
3946
static inline struct device *dt_idle_attach_cpu(int cpu, const char *name)
4047
{
4148
return NULL;

0 commit comments

Comments
 (0)