Skip to content

Commit 68090fd

Browse files
javiercarrascocruzvireshk
authored andcommitted
cpufreq: dt: eliminate uses of of_node_put()
Make use of the __free() cleanup handler to automatically free nodes when they get out of scope. Only find_supply_name() is affected, and the new mechanism removes the need for a 'goto' and the 'name' local variable. Signed-off-by: Javier Carrasco <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent d769eae commit 68090fd

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

drivers/cpufreq/cpufreq-dt.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,9 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
6868
*/
6969
static const char *find_supply_name(struct device *dev)
7070
{
71-
struct device_node *np;
71+
struct device_node *np __free(device_node) = of_node_get(dev->of_node);
7272
struct property *pp;
7373
int cpu = dev->id;
74-
const char *name = NULL;
75-
76-
np = of_node_get(dev->of_node);
7774

7875
/* This must be valid for sure */
7976
if (WARN_ON(!np))
@@ -82,22 +79,16 @@ static const char *find_supply_name(struct device *dev)
8279
/* Try "cpu0" for older DTs */
8380
if (!cpu) {
8481
pp = of_find_property(np, "cpu0-supply", NULL);
85-
if (pp) {
86-
name = "cpu0";
87-
goto node_put;
88-
}
82+
if (pp)
83+
return "cpu0";
8984
}
9085

9186
pp = of_find_property(np, "cpu-supply", NULL);
92-
if (pp) {
93-
name = "cpu";
94-
goto node_put;
95-
}
87+
if (pp)
88+
return "cpu";
9689

9790
dev_dbg(dev, "no regulator for cpu%d\n", cpu);
98-
node_put:
99-
of_node_put(np);
100-
return name;
91+
return NULL;
10192
}
10293

10394
static int cpufreq_init(struct cpufreq_policy *policy)

0 commit comments

Comments
 (0)