Skip to content

Commit 872cc94

Browse files
robherringvireshk
authored andcommitted
cpufreq: Use of_property_present()
Use of_property_present() to test for property presence rather than of_(find|get)_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_find_property() leaks the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed. Signed-off-by: Rob Herring (Arm) <[email protected]> Acked-by: Chen-Yu Tsai <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent 8400291 commit 872cc94

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

drivers/cpufreq/cpufreq-dt.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,17 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
6969
static const char *find_supply_name(struct device *dev)
7070
{
7171
struct device_node *np __free(device_node) = of_node_get(dev->of_node);
72-
struct property *pp;
7372
int cpu = dev->id;
7473

7574
/* This must be valid for sure */
7675
if (WARN_ON(!np))
7776
return NULL;
7877

7978
/* Try "cpu0" for older DTs */
80-
if (!cpu) {
81-
pp = of_find_property(np, "cpu0-supply", NULL);
82-
if (pp)
83-
return "cpu0";
84-
}
79+
if (!cpu && of_property_present(np, "cpu0-supply"))
80+
return "cpu0";
8581

86-
pp = of_find_property(np, "cpu-supply", NULL);
87-
if (pp)
82+
if (of_property_present(np, "cpu-supply"))
8883
return "cpu";
8984

9085
dev_dbg(dev, "no regulator for cpu%d\n", cpu);

drivers/cpufreq/pmac64-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode)
505505
continue;
506506
if (strcmp(loc, "CPU CLOCK"))
507507
continue;
508-
if (!of_get_property(hwclock, "platform-get-frequency", NULL))
508+
if (!of_property_present(hwclock, "platform-get-frequency"))
509509
continue;
510510
break;
511511
}

drivers/cpufreq/sti-cpufreq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static int __init sti_cpufreq_init(void)
267267
goto skip_voltage_scaling;
268268
}
269269

270-
if (!of_get_property(ddata.cpu->of_node, "operating-points-v2", NULL)) {
270+
if (!of_property_present(ddata.cpu->of_node, "operating-points-v2")) {
271271
dev_err(ddata.cpu, "OPP-v2 not supported\n");
272272
goto skip_voltage_scaling;
273273
}

drivers/cpufreq/sun50i-cpufreq-nvmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static bool dt_has_supported_hw(void)
146146
return false;
147147

148148
for_each_child_of_node_scoped(np, opp) {
149-
if (of_find_property(opp, "opp-supported-hw", NULL)) {
149+
if (of_property_present(opp, "opp-supported-hw")) {
150150
has_opp_supported_hw = true;
151151
break;
152152
}

0 commit comments

Comments
 (0)