Thread (34 messages) 34 messages, 7 authors, 2026-01-10

Re: [PATCH 11/11] cpufreq: s5pv210: Simplify with scoped for each OF child loop

From: Jonathan Cameron <jonathan.cameron@huawei.com>
Date: 2026-01-06 10:35:21
Also in: dmaengine, imx, linux-arm-kernel, linux-clk, linux-devicetree, linux-media, linux-pm, linux-samsung-soc, lkml, llvm

On Mon, 05 Jan 2026 14:33:49 +0100
Krzysztof Kozlowski [off-list ref] wrote:
Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.  Note that there is another part of code using "np"
variable, so scoped loop should not shadow it.

Signed-off-by: Krzysztof Kozlowski <redacted>
Patch is fine so
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

Bit odd to use devm_ for a driver that has no real support for being unbound
(looks like it leaks everything if that happens) but to me it looks like
it might be worth doing anyway to allow direct returns in error
cases etc.  Anyhow, that's a much bigger looking project and would need
a devm_add_action_or_reset() for the final register and someone to test
it doesn't blow up if an unbind does happen.

One of the things I like about reviewing this sort of cleanup series
is it makes me look at a bunch of code I'd never normally go see ;)

Jonathan
quoted hunk ↗ jump to hunk
---

Depends on the first patch.
---
 drivers/cpufreq/s5pv210-cpufreq.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index ba8a1c96427a..e64e84e1ee79 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -629,19 +629,17 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
 		goto err_clock;
 	}
 
-	for_each_compatible_node(np, NULL, "samsung,s5pv210-dmc") {
-		id = of_alias_get_id(np, "dmc");
+	for_each_compatible_node_scoped(dmc, NULL, "samsung,s5pv210-dmc") {
+		id = of_alias_get_id(dmc, "dmc");
 		if (id < 0 || id >= ARRAY_SIZE(dmc_base)) {
-			dev_err(dev, "failed to get alias of dmc node '%pOFn'\n", np);
-			of_node_put(np);
+			dev_err(dev, "failed to get alias of dmc node '%pOFn'\n", dmc);
 			result = id;
 			goto err_clk_base;
 		}
 
-		dmc_base[id] = of_iomap(np, 0);
+		dmc_base[id] = of_iomap(dmc, 0);
 		if (!dmc_base[id]) {
 			dev_err(dev, "failed to map dmc%d registers\n", id);
-			of_node_put(np);
 			result = -EFAULT;
 			goto err_dmc;
 		}
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help