linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Use of_property_present()
@ 2024-07-31 19:12 Rob Herring (Arm)
  2024-08-01  3:41 ` Chen-Yu Tsai
  2024-08-01  5:51 ` Viresh Kumar
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring (Arm) @ 2024-07-31 19:12 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao, Patrice Chotard,
	Yangtao Li, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
  Cc: linux-sunxi, linuxppc-dev, linux-kernel, linux-arm-kernel,
	linux-pm

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>
---
 drivers/cpufreq/cpufreq-dt.c           | 11 +++--------
 drivers/cpufreq/pmac64-cpufreq.c       |  2 +-
 drivers/cpufreq/sti-cpufreq.c          |  2 +-
 drivers/cpufreq/sun50i-cpufreq-nvmem.c |  2 +-
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 6532c4d71338..983443396f8f 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -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);
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 2cd2b06849a2..c87cd6e0b638 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -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;
 	}
diff --git a/drivers/cpufreq/sti-cpufreq.c b/drivers/cpufreq/sti-cpufreq.c
index 8e2e703c3865..b15b3142b5fe 100644
--- a/drivers/cpufreq/sti-cpufreq.c
+++ b/drivers/cpufreq/sti-cpufreq.c
@@ -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;
 	}
diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
index 95ac8d46c156..293921acec93 100644
--- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c
+++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c
@@ -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;
 		}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufreq: Use of_property_present()
  2024-07-31 19:12 [PATCH] cpufreq: Use of_property_present() Rob Herring (Arm)
@ 2024-08-01  3:41 ` Chen-Yu Tsai
  2024-08-01  5:51 ` Viresh Kumar
  1 sibling, 0 replies; 3+ messages in thread
From: Chen-Yu Tsai @ 2024-08-01  3:41 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Jernej Skrabec, Rafael J. Wysocki, Yangtao Li, Viresh Kumar,
	linux-pm, Samuel Holland, Naveen N Rao, Christophe Leroy,
	linux-kernel, linux-sunxi, Nicholas Piggin, linuxppc-dev,
	Patrice Chotard, linux-arm-kernel

On Thu, Aug 1, 2024 at 3:13 AM Rob Herring (Arm) <robh@kernel.org> wrote:
>
> 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>
> ---
>  drivers/cpufreq/cpufreq-dt.c           | 11 +++--------
>  drivers/cpufreq/pmac64-cpufreq.c       |  2 +-
>  drivers/cpufreq/sti-cpufreq.c          |  2 +-

>  drivers/cpufreq/sun50i-cpufreq-nvmem.c |  2 +-

Acked-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufreq: Use of_property_present()
  2024-07-31 19:12 [PATCH] cpufreq: Use of_property_present() Rob Herring (Arm)
  2024-08-01  3:41 ` Chen-Yu Tsai
@ 2024-08-01  5:51 ` Viresh Kumar
  1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2024-08-01  5:51 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Jernej Skrabec, Rafael J. Wysocki, Yangtao Li, linux-pm,
	Samuel Holland, Naveen N Rao, Christophe Leroy, linux-kernel,
	linux-sunxi, Chen-Yu Tsai, Nicholas Piggin, linuxppc-dev,
	Patrice Chotard, linux-arm-kernel

On 31-07-24, 13:12, Rob Herring (Arm) wrote:
> 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>
> ---
>  drivers/cpufreq/cpufreq-dt.c           | 11 +++--------
>  drivers/cpufreq/pmac64-cpufreq.c       |  2 +-
>  drivers/cpufreq/sti-cpufreq.c          |  2 +-
>  drivers/cpufreq/sun50i-cpufreq-nvmem.c |  2 +-
>  4 files changed, 6 insertions(+), 11 deletions(-)

Applied. Thanks.

-- 
viresh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-01  5:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 19:12 [PATCH] cpufreq: Use of_property_present() Rob Herring (Arm)
2024-08-01  3:41 ` Chen-Yu Tsai
2024-08-01  5:51 ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).