]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpufreq: Use of_property_present()
authorRob Herring (Arm) <robh@kernel.org>
Wed, 31 Jul 2024 19:12:40 +0000 (13:12 -0600)
committerViresh Kumar <viresh.kumar@linaro.org>
Wed, 7 Aug 2024 06:41:45 +0000 (12:11 +0530)
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) <robh@kernel.org>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/cpufreq-dt.c
drivers/cpufreq/pmac64-cpufreq.c
drivers/cpufreq/sti-cpufreq.c
drivers/cpufreq/sun50i-cpufreq-nvmem.c

index 6532c4d713382535606b87dc8a7779fbac139eca..983443396f8f22cd8e3d48840ae4894d459a8bbe 100644 (file)
@@ -69,7 +69,6 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index)
 static const char *find_supply_name(struct device *dev)
 {
        struct device_node *np __free(device_node) = of_node_get(dev->of_node);
-       struct property *pp;
        int cpu = dev->id;
 
        /* This must be valid for sure */
@@ -77,14 +76,10 @@ static const char *find_supply_name(struct device *dev)
                return NULL;
 
        /* Try "cpu0" for older DTs */
-       if (!cpu) {
-               pp = of_find_property(np, "cpu0-supply", NULL);
-               if (pp)
-                       return "cpu0";
-       }
+       if (!cpu && of_property_present(np, "cpu0-supply"))
+               return "cpu0";
 
-       pp = of_find_property(np, "cpu-supply", NULL);
-       if (pp)
+       if (of_property_present(np, "cpu-supply"))
                return "cpu";
 
        dev_dbg(dev, "no regulator for cpu%d\n", cpu);
index 2cd2b06849a23d28877d432652956f640e59fac4..c87cd6e0b638866c424f7f78c665f86ef2779e80 100644 (file)
@@ -505,7 +505,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode)
                        continue;
                if (strcmp(loc, "CPU CLOCK"))
                        continue;
-               if (!of_get_property(hwclock, "platform-get-frequency", NULL))
+               if (!of_property_present(hwclock, "platform-get-frequency"))
                        continue;
                break;
        }
index 8e2e703c3865d911776c64788f4f766094998a8f..b15b3142b5fec3e1c594de836289b0f04a82f516 100644 (file)
@@ -267,7 +267,7 @@ static int __init sti_cpufreq_init(void)
                goto skip_voltage_scaling;
        }
 
-       if (!of_get_property(ddata.cpu->of_node, "operating-points-v2", NULL)) {
+       if (!of_property_present(ddata.cpu->of_node, "operating-points-v2")) {
                dev_err(ddata.cpu, "OPP-v2 not supported\n");
                goto skip_voltage_scaling;
        }
index 95ac8d46c1563ec06a590741319b7ee425d0b881..293921acec93781f20f48f19666d4bab435d9b58 100644 (file)
@@ -146,7 +146,7 @@ static bool dt_has_supported_hw(void)
                return false;
 
        for_each_child_of_node_scoped(np, opp) {
-               if (of_find_property(opp, "opp-supported-hw", NULL)) {
+               if (of_property_present(opp, "opp-supported-hw")) {
                        has_opp_supported_hw = true;
                        break;
                }