public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped()
@ 2026-01-09 16:57 Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 01/12] of: Add for_each_compatible_node_scoped() helper Krzysztof Kozlowski
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski,
	Frank Li

Dependencies/merging
====================
1. First patch is a prerequisite for entire set, so either everything
   goes via same tree, the further patches wait a cycle or stable tag is
   shared from DT tree.

2. The last media patch depends on my earlier cleanup.

Changes in v3:
- New patch: cdx: Use mutex guard to simplify error handling
- Collect tags
- Link to v2: https://patch.msgid.link/20260106-of-for-each-compatible-scoped-v2-0-05eb948d91f2@oss.qualcomm.com

Changes in v2:
- Update also scripts/dtc/dt-extract-compatibles (Rob)
- Collect tags
- Link to v1: https://patch.msgid.link/20260105-of-for-each-compatible-scoped-v1-0-24e99c177164@oss.qualcomm.com

Description
===========
Simplify for_each_compatible_node() users with a new helper -
for_each_compatible_node_scoped().

Best regards,
Krzysztof

---
Krzysztof Kozlowski (12):
      of: Add for_each_compatible_node_scoped() helper
      ARM: at91: Simplify with scoped for each OF child loop
      ARM: exynos: Simplify with scoped for each OF child loop
      powerpc/fsp2: Simplify with scoped for each OF child loop
      powerpc/wii: Simplify with scoped for each OF child loop
      cdx: Simplify with scoped for each OF child loop
      cdx: Use mutex guard to simplify error handling
      clk: imx: imx27: Simplify with scoped for each OF child loop
      clk: imx: imx31: Simplify with scoped for each OF child loop
      dmaengine: fsl_raid: Simplify with scoped for each OF child loop
      cpufreq: s5pv210: Simplify with scoped for each OF child loop
      media: samsung: exynos4-is: Simplify with scoped for each OF child loop

 .clang-format                                       |  1 +
 arch/arm/mach-at91/pm.c                             |  7 ++-----
 arch/arm/mach-exynos/exynos.c                       |  8 ++------
 arch/powerpc/platforms/44x/fsp2.c                   |  5 +----
 arch/powerpc/platforms/embedded6xx/hlwd-pic.c       |  4 +---
 drivers/cdx/cdx.c                                   | 15 ++++-----------
 drivers/clk/imx/clk-imx27.c                         |  7 ++-----
 drivers/clk/imx/clk-imx31.c                         |  7 ++-----
 drivers/cpufreq/s5pv210-cpufreq.c                   | 10 ++++------
 drivers/dma/fsl_raid.c                              |  4 +---
 drivers/media/platform/samsung/exynos4-is/fimc-is.c |  8 +++-----
 include/linux/of.h                                  |  7 +++++++
 scripts/dtc/dt-extract-compatibles                  |  1 +
 13 files changed, 31 insertions(+), 53 deletions(-)
---
base-commit: 4d27ce1b1abefb22e277e715901cc52acdc5af2c
change-id: 20260105-of-for-each-compatible-scoped-285b3dbda253

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>


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

* [PATCH v3 01/12] of: Add for_each_compatible_node_scoped() helper
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 02/12] ARM: at91: Simplify with scoped for each OF child loop Krzysztof Kozlowski
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

Just like looping through children and available children, add a scoped
helper for for_each_compatible_node() so error paths can drop
of_node_put() leading to simpler code.

Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Prerequisite for all further patches.
---
 .clang-format                      | 1 +
 include/linux/of.h                 | 7 +++++++
 scripts/dtc/dt-extract-compatibles | 1 +
 3 files changed, 9 insertions(+)

diff --git a/.clang-format b/.clang-format
index c7060124a47a..1cc151e2adcc 100644
--- a/.clang-format
+++ b/.clang-format
@@ -259,6 +259,7 @@ ForEachMacros:
   - 'for_each_collection'
   - 'for_each_comp_order'
   - 'for_each_compatible_node'
+  - 'for_each_compatible_node_scoped'
   - 'for_each_component_dais'
   - 'for_each_component_dais_safe'
   - 'for_each_conduit'
diff --git a/include/linux/of.h b/include/linux/of.h
index 9bbdcf25a2b4..be6ec4916adf 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1485,6 +1485,13 @@ static inline int of_property_read_s32(const struct device_node *np,
 #define for_each_compatible_node(dn, type, compatible) \
 	for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
 	     dn = of_find_compatible_node(dn, type, compatible))
+
+#define for_each_compatible_node_scoped(dn, type, compatible) \
+	for (struct device_node *dn __free(device_node) =		\
+	     of_find_compatible_node(NULL, type, compatible);		\
+	     dn;							\
+	     dn = of_find_compatible_node(dn, type, compatible))
+
 #define for_each_matching_node(dn, matches) \
 	for (dn = of_find_matching_node(NULL, matches); dn; \
 	     dn = of_find_matching_node(dn, matches))
diff --git a/scripts/dtc/dt-extract-compatibles b/scripts/dtc/dt-extract-compatibles
index 6570efabaa64..87999d707390 100755
--- a/scripts/dtc/dt-extract-compatibles
+++ b/scripts/dtc/dt-extract-compatibles
@@ -72,6 +72,7 @@ def parse_compatibles(file, compat_ignore_list):
 		compat_list += parse_of_functions(data, "_is_compatible")
 		compat_list += parse_of_functions(data, "of_find_compatible_node")
 		compat_list += parse_of_functions(data, "for_each_compatible_node")
+		compat_list += parse_of_functions(data, "for_each_compatible_node_scoped")
 		compat_list += parse_of_functions(data, "of_get_compatible_child")
 
 	return compat_list

-- 
2.51.0


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

* [PATCH v3 02/12] ARM: at91: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 01/12] of: Add for_each_compatible_node_scoped() helper Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-10 15:09   ` Claudiu Beznea
  2026-01-09 16:57 ` [PATCH v3 03/12] ARM: exynos: " Krzysztof Kozlowski
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on the first patch.
---
 arch/arm/mach-at91/pm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 35058b99069c..68bb4a86cd94 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -982,15 +982,12 @@ static void __init at91_pm_sram_init(void)
 	struct gen_pool *sram_pool;
 	phys_addr_t sram_pbase;
 	unsigned long sram_base;
-	struct device_node *node;
 	struct platform_device *pdev = NULL;
 
-	for_each_compatible_node(node, NULL, "mmio-sram") {
+	for_each_compatible_node_scoped(node, NULL, "mmio-sram") {
 		pdev = of_find_device_by_node(node);
-		if (pdev) {
-			of_node_put(node);
+		if (pdev)
 			break;
-		}
 	}
 
 	if (!pdev) {

-- 
2.51.0


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

* [PATCH v3 03/12] ARM: exynos: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 01/12] of: Add for_each_compatible_node_scoped() helper Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 02/12] ARM: at91: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 04/12] powerpc/fsp2: " Krzysztof Kozlowski
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on the first patch.
---
 arch/arm/mach-exynos/exynos.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 2e8099479ffa..18695076c34e 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -47,9 +47,7 @@ unsigned int exynos_rev(void)
 
 void __init exynos_sysram_init(void)
 {
-	struct device_node *node;
-
-	for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram") {
+	for_each_compatible_node_scoped(node, NULL, "samsung,exynos4210-sysram") {
 		struct resource res;
 		if (!of_device_is_available(node))
 			continue;
@@ -57,15 +55,13 @@ void __init exynos_sysram_init(void)
 		of_address_to_resource(node, 0, &res);
 		sysram_base_addr = ioremap(res.start, resource_size(&res));
 		sysram_base_phys = res.start;
-		of_node_put(node);
 		break;
 	}
 
-	for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram-ns") {
+	for_each_compatible_node_scoped(node, NULL, "samsung,exynos4210-sysram-ns") {
 		if (!of_device_is_available(node))
 			continue;
 		sysram_ns_base_addr = of_iomap(node, 0);
-		of_node_put(node);
 		break;
 	}
 }

-- 
2.51.0


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

* [PATCH v3 04/12] powerpc/fsp2: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 03/12] ARM: exynos: " Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 17:21   ` Christophe Leroy (CS GROUP)
  2026-01-09 16:57 ` [PATCH v3 05/12] powerpc/wii: " Krzysztof Kozlowski
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on the first patch.
---
 arch/powerpc/platforms/44x/fsp2.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c b/arch/powerpc/platforms/44x/fsp2.c
index f6b8d02e08b0..b06d9220844c 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -199,16 +199,14 @@ static irqreturn_t rst_wrn_handler(int irq, void *data) {
 
 static void __init node_irq_request(const char *compat, irq_handler_t errirq_handler)
 {
-	struct device_node *np;
 	unsigned int irq;
 	int32_t rc;
 
-	for_each_compatible_node(np, NULL, compat) {
+	for_each_compatible_node_scoped(np, NULL, compat) {
 		irq = irq_of_parse_and_map(np, 0);
 		if (!irq) {
 			pr_err("device tree node %pOFn is missing a interrupt",
 			      np);
-			of_node_put(np);
 			return;
 		}
 
@@ -216,7 +214,6 @@ static void __init node_irq_request(const char *compat, irq_handler_t errirq_han
 		if (rc) {
 			pr_err("fsp_of_probe: request_irq failed: np=%pOF rc=%d",
 			      np, rc);
-			of_node_put(np);
 			return;
 		}
 	}

-- 
2.51.0


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

* [PATCH v3 05/12] powerpc/wii: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 04/12] powerpc/fsp2: " Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 17:22   ` Christophe Leroy (CS GROUP)
  2026-01-09 16:57 ` [PATCH v3 06/12] cdx: " Krzysztof Kozlowski
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on the first patch.
---
 arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
index b57e87b0b3ce..1522a8bece29 100644
--- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
+++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
@@ -201,11 +201,10 @@ unsigned int hlwd_pic_get_irq(void)
 void __init hlwd_pic_probe(void)
 {
 	struct irq_domain *host;
-	struct device_node *np;
 	const u32 *interrupts;
 	int cascade_virq;
 
-	for_each_compatible_node(np, NULL, "nintendo,hollywood-pic") {
+	for_each_compatible_node_scoped(np, NULL, "nintendo,hollywood-pic") {
 		interrupts = of_get_property(np, "interrupts", NULL);
 		if (interrupts) {
 			host = hlwd_pic_init(np);
@@ -215,7 +214,6 @@ void __init hlwd_pic_probe(void)
 			irq_set_chained_handler(cascade_virq,
 						hlwd_pic_irq_cascade);
 			hlwd_irq_host = host;
-			of_node_put(np);
 			break;
 		}
 	}

-- 
2.51.0


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

* [PATCH v3 06/12] cdx: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 05/12] powerpc/wii: " Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-12 12:48   ` Jonathan Cameron
  2026-01-09 16:57 ` [PATCH v3 07/12] cdx: Use mutex guard to simplify error handling Krzysztof Kozlowski
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

---

Depends on the first patch.
---
 drivers/cdx/cdx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
index b39af2f1937f..bbde529aaa93 100644
--- a/drivers/cdx/cdx.c
+++ b/drivers/cdx/cdx.c
@@ -608,7 +608,6 @@ static ssize_t rescan_store(const struct bus_type *bus,
 {
 	struct cdx_controller *cdx;
 	struct platform_device *pd;
-	struct device_node *np;
 	bool val;
 
 	if (kstrtobool(buf, &val) < 0)
@@ -623,10 +622,9 @@ static ssize_t rescan_store(const struct bus_type *bus,
 	cdx_unregister_devices(&cdx_bus_type);
 
 	/* Rescan all the devices */
-	for_each_compatible_node(np, NULL, compat_node_name) {
+	for_each_compatible_node_scoped(np, NULL, compat_node_name) {
 		pd = of_find_device_by_node(np);
 		if (!pd) {
-			of_node_put(np);
 			count = -EINVAL;
 			goto unlock;
 		}

-- 
2.51.0


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

* [PATCH v3 07/12] cdx: Use mutex guard to simplify error handling
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (5 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 06/12] cdx: " Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-12 12:48   ` Jonathan Cameron
  2026-01-09 16:57 ` [PATCH v3 08/12] clk: imx: imx27: Simplify with scoped for each OF child loop Krzysztof Kozlowski
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

Mutex guard allows to drop one goto/break in error handling and the
less expected code of assigning -EINVAL to unsigned size_t count
variable.

Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/cdx/cdx.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
index bbde529aaa93..588dd12e8105 100644
--- a/drivers/cdx/cdx.c
+++ b/drivers/cdx/cdx.c
@@ -616,7 +616,7 @@ static ssize_t rescan_store(const struct bus_type *bus,
 	if (!val)
 		return -EINVAL;
 
-	mutex_lock(&cdx_controller_lock);
+	guard(mutex)(&cdx_controller_lock);
 
 	/* Unregister all the devices on the bus */
 	cdx_unregister_devices(&cdx_bus_type);
@@ -624,10 +624,8 @@ static ssize_t rescan_store(const struct bus_type *bus,
 	/* Rescan all the devices */
 	for_each_compatible_node_scoped(np, NULL, compat_node_name) {
 		pd = of_find_device_by_node(np);
-		if (!pd) {
-			count = -EINVAL;
-			goto unlock;
-		}
+		if (!pd)
+			return -EINVAL;
 
 		cdx = platform_get_drvdata(pd);
 		if (cdx && cdx->controller_registered && cdx->ops->scan)
@@ -636,9 +634,6 @@ static ssize_t rescan_store(const struct bus_type *bus,
 		put_device(&pd->dev);
 	}
 
-unlock:
-	mutex_unlock(&cdx_controller_lock);
-
 	return count;
 }
 static BUS_ATTR_WO(rescan);

-- 
2.51.0


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

* [PATCH v3 08/12] clk: imx: imx27: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (6 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 07/12] cdx: Use mutex guard to simplify error handling Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 09/12] clk: imx: imx31: " Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Frank Li,
	Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Abel Vesa <abelvesa@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on first patch.
---
 drivers/clk/imx/clk-imx27.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/imx/clk-imx27.c b/drivers/clk/imx/clk-imx27.c
index 99618ded0939..f2f0d3fe5c52 100644
--- a/drivers/clk/imx/clk-imx27.c
+++ b/drivers/clk/imx/clk-imx27.c
@@ -171,17 +171,14 @@ static void __init _mx27_clocks_init(unsigned long fref)
 
 static void __init mx27_clocks_init_dt(struct device_node *np)
 {
-	struct device_node *refnp;
 	u32 fref = 26000000; /* default */
 
-	for_each_compatible_node(refnp, NULL, "fixed-clock") {
+	for_each_compatible_node_scoped(refnp, NULL, "fixed-clock") {
 		if (!of_device_is_compatible(refnp, "fsl,imx-osc26m"))
 			continue;
 
-		if (!of_property_read_u32(refnp, "clock-frequency", &fref)) {
-			of_node_put(refnp);
+		if (!of_property_read_u32(refnp, "clock-frequency", &fref))
 			break;
-		}
 	}
 
 	ccm = of_iomap(np, 0);

-- 
2.51.0


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

* [PATCH v3 09/12] clk: imx: imx31: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (7 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 08/12] clk: imx: imx27: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 10/12] dmaengine: fsl_raid: " Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Frank Li,
	Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Abel Vesa <abelvesa@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on first patch.
---
 drivers/clk/imx/clk-imx31.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
index 4c8d9ff0b2ad..962eccac63ce 100644
--- a/drivers/clk/imx/clk-imx31.c
+++ b/drivers/clk/imx/clk-imx31.c
@@ -123,18 +123,15 @@ static void __init _mx31_clocks_init(void __iomem *base, unsigned long fref)
 
 static void __init mx31_clocks_init_dt(struct device_node *np)
 {
-	struct device_node *osc_np;
 	u32 fref = 26000000; /* default */
 	void __iomem *ccm;
 
-	for_each_compatible_node(osc_np, NULL, "fixed-clock") {
+	for_each_compatible_node_scoped(osc_np, NULL, "fixed-clock") {
 		if (!of_device_is_compatible(osc_np, "fsl,imx-osc26m"))
 			continue;
 
-		if (!of_property_read_u32(osc_np, "clock-frequency", &fref)) {
-			of_node_put(osc_np);
+		if (!of_property_read_u32(osc_np, "clock-frequency", &fref))
 			break;
-		}
 	}
 
 	ccm = of_iomap(np, 0);

-- 
2.51.0


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

* [PATCH v3 10/12] dmaengine: fsl_raid: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (8 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 09/12] clk: imx: imx31: " Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 11/12] cpufreq: s5pv210: " Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Frank Li,
	Krzysztof Kozlowski

Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on the first patch.
---
 drivers/dma/fsl_raid.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/fsl_raid.c b/drivers/dma/fsl_raid.c
index 6aa97e258a55..6e6d7e0e475e 100644
--- a/drivers/dma/fsl_raid.c
+++ b/drivers/dma/fsl_raid.c
@@ -746,7 +746,6 @@ static int fsl_re_chan_probe(struct platform_device *ofdev,
 static int fsl_re_probe(struct platform_device *ofdev)
 {
 	struct fsl_re_drv_private *re_priv;
-	struct device_node *np;
 	struct device_node *child;
 	u32 off;
 	u8 ridx = 0;
@@ -823,11 +822,10 @@ static int fsl_re_probe(struct platform_device *ofdev)
 	dev_set_drvdata(dev, re_priv);
 
 	/* Parse Device tree to find out the total number of JQs present */
-	for_each_compatible_node(np, NULL, "fsl,raideng-v1.0-job-queue") {
+	for_each_compatible_node_scoped(np, NULL, "fsl,raideng-v1.0-job-queue") {
 		rc = of_property_read_u32(np, "reg", &off);
 		if (rc) {
 			dev_err(dev, "Reg property not found in JQ node\n");
-			of_node_put(np);
 			return -ENODEV;
 		}
 		/* Find out the Job Rings present under each JQ */

-- 
2.51.0


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

* [PATCH v3 11/12] cpufreq: s5pv210: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (9 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 10/12] dmaengine: fsl_raid: " Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-09 16:57 ` [PATCH v3 12/12] media: samsung: exynos4-is: " Krzysztof Kozlowski
  2026-01-29 17:14 ` [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Rob Herring
  12 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

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.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

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;
 		}

-- 
2.51.0


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

* [PATCH v3 12/12] media: samsung: exynos4-is: Simplify with scoped for each OF child loop
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (10 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 11/12] cpufreq: s5pv210: " Krzysztof Kozlowski
@ 2026-01-09 16:57 ` Krzysztof Kozlowski
  2026-01-29 17:14 ` [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Rob Herring
  12 siblings, 0 replies; 19+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 16:57 UTC (permalink / raw)
  To: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Krzysztof Kozlowski

Use scoped for_each_compatible_node_scoped() loop when iterating over
device nodes to make code a bit simpler.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---

Depends on the first patch and on:
https://lore.kernel.org/all/20260102124955.64904-2-krzysztof.kozlowski@oss.qualcomm.com/
---
 drivers/media/platform/samsung/exynos4-is/fimc-is.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
index 14d84cc96831..b7d9bfedd590 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
@@ -200,21 +200,19 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
 
 static int fimc_is_register_subdevs(struct fimc_is *is)
 {
-	struct device_node *i2c_bus;
 	int ret, index = 0;
 
 	ret = fimc_isp_subdev_create(&is->isp);
 	if (ret < 0)
 		return ret;
 
-	for_each_compatible_node(i2c_bus, NULL, "samsung,exynos4212-i2c-isp") {
+	for_each_compatible_node_scoped(i2c_bus, NULL, "samsung,exynos4212-i2c-isp") {
 		for_each_available_child_of_node_scoped(i2c_bus, child) {
 			ret = fimc_is_parse_sensor_config(is, index, child);
 
-			if (ret < 0 || index >= FIMC_IS_SENSORS_NUM) {
-				of_node_put(i2c_bus);
+			if (ret < 0 || index >= FIMC_IS_SENSORS_NUM)
 				return ret;
-			}
+
 			index++;
 		}
 	}

-- 
2.51.0


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

* Re: [PATCH v3 04/12] powerpc/fsp2: Simplify with scoped for each OF child loop
  2026-01-09 16:57 ` [PATCH v3 04/12] powerpc/fsp2: " Krzysztof Kozlowski
@ 2026-01-09 17:21   ` Christophe Leroy (CS GROUP)
  0 siblings, 0 replies; 19+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-01-09 17:21 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Miguel Ojeda, Rob Herring, Saravana Kannan,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Russell King, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Nipun Gupta, Nikhil Agarwal,
	Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron



Le 09/01/2026 à 17:57, Krzysztof Kozlowski a écrit :
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
> 
> Depends on the first patch.
> ---
>   arch/powerpc/platforms/44x/fsp2.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/44x/fsp2.c b/arch/powerpc/platforms/44x/fsp2.c
> index f6b8d02e08b0..b06d9220844c 100644
> --- a/arch/powerpc/platforms/44x/fsp2.c
> +++ b/arch/powerpc/platforms/44x/fsp2.c
> @@ -199,16 +199,14 @@ static irqreturn_t rst_wrn_handler(int irq, void *data) {
>   
>   static void __init node_irq_request(const char *compat, irq_handler_t errirq_handler)
>   {
> -	struct device_node *np;
>   	unsigned int irq;
>   	int32_t rc;
>   
> -	for_each_compatible_node(np, NULL, compat) {
> +	for_each_compatible_node_scoped(np, NULL, compat) {
>   		irq = irq_of_parse_and_map(np, 0);
>   		if (!irq) {
>   			pr_err("device tree node %pOFn is missing a interrupt",
>   			      np);
> -			of_node_put(np);
>   			return;
>   		}
>   
> @@ -216,7 +214,6 @@ static void __init node_irq_request(const char *compat, irq_handler_t errirq_han
>   		if (rc) {
>   			pr_err("fsp_of_probe: request_irq failed: np=%pOF rc=%d",
>   			      np, rc);
> -			of_node_put(np);
>   			return;
>   		}
>   	}
> 


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

* Re: [PATCH v3 05/12] powerpc/wii: Simplify with scoped for each OF child loop
  2026-01-09 16:57 ` [PATCH v3 05/12] powerpc/wii: " Krzysztof Kozlowski
@ 2026-01-09 17:22   ` Christophe Leroy (CS GROUP)
  0 siblings, 0 replies; 19+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-01-09 17:22 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Miguel Ojeda, Rob Herring, Saravana Kannan,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Russell King, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Nipun Gupta, Nikhil Agarwal,
	Abel Vesa, Peng Fan, Michael Turquette, Stephen Boyd, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron



Le 09/01/2026 à 17:57, Krzysztof Kozlowski a écrit :
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>

> ---
> 
> Depends on the first patch.
> ---
>   arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
> index b57e87b0b3ce..1522a8bece29 100644
> --- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
> +++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
> @@ -201,11 +201,10 @@ unsigned int hlwd_pic_get_irq(void)
>   void __init hlwd_pic_probe(void)
>   {
>   	struct irq_domain *host;
> -	struct device_node *np;
>   	const u32 *interrupts;
>   	int cascade_virq;
>   
> -	for_each_compatible_node(np, NULL, "nintendo,hollywood-pic") {
> +	for_each_compatible_node_scoped(np, NULL, "nintendo,hollywood-pic") {
>   		interrupts = of_get_property(np, "interrupts", NULL);
>   		if (interrupts) {
>   			host = hlwd_pic_init(np);
> @@ -215,7 +214,6 @@ void __init hlwd_pic_probe(void)
>   			irq_set_chained_handler(cascade_virq,
>   						hlwd_pic_irq_cascade);
>   			hlwd_irq_host = host;
> -			of_node_put(np);
>   			break;
>   		}
>   	}
> 


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

* Re: [PATCH v3 02/12] ARM: at91: Simplify with scoped for each OF child loop
  2026-01-09 16:57 ` [PATCH v3 02/12] ARM: at91: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-10 15:09   ` Claudiu Beznea
  0 siblings, 0 replies; 19+ messages in thread
From: Claudiu Beznea @ 2026-01-10 15:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Miguel Ojeda, Rob Herring, Saravana Kannan,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Russell King, Nicolas Ferre, Alexandre Belloni,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar
  Cc: linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron



On 1/9/26 18:57, Krzysztof Kozlowski wrote:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>

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

* Re: [PATCH v3 06/12] cdx: Simplify with scoped for each OF child loop
  2026-01-09 16:57 ` [PATCH v3 06/12] cdx: " Krzysztof Kozlowski
@ 2026-01-12 12:48   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2026-01-12 12:48 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar, linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm

On Fri, 09 Jan 2026 17:57:50 +0100
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> wrote:

> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
but only on basis next one merges as well just for that 'obey the strict
rules in cleanup.h'.

No bug bug I like not having to think about whether there is or not :)

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

* Re: [PATCH v3 07/12] cdx: Use mutex guard to simplify error handling
  2026-01-09 16:57 ` [PATCH v3 07/12] cdx: Use mutex guard to simplify error handling Krzysztof Kozlowski
@ 2026-01-12 12:48   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2026-01-12 12:48 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Miguel Ojeda, Rob Herring, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar, linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm

On Fri, 09 Jan 2026 17:57:51 +0100
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> wrote:

> Mutex guard allows to drop one goto/break in error handling and the
> less expected code of assigning -EINVAL to unsigned size_t count
> variable.
> 
> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

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

* Re: [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped()
  2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
                   ` (11 preceding siblings ...)
  2026-01-09 16:57 ` [PATCH v3 12/12] media: samsung: exynos4-is: " Krzysztof Kozlowski
@ 2026-01-29 17:14 ` Rob Herring
  12 siblings, 0 replies; 19+ messages in thread
From: Rob Herring @ 2026-01-29 17:14 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Miguel Ojeda, Saravana Kannan, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Russell King,
	Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Krzysztof Kozlowski, Alim Akhtar, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
	Nipun Gupta, Nikhil Agarwal, Abel Vesa, Peng Fan,
	Michael Turquette, Stephen Boyd, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Vinod Koul,
	Sylwester Nawrocki, Mauro Carvalho Chehab, Rafael J. Wysocki,
	Viresh Kumar, linux-kernel, devicetree, llvm, linux-arm-kernel,
	linux-samsung-soc, linuxppc-dev, linux-clk, imx, dmaengine,
	linux-media, linux-pm, Jonathan Cameron, Frank Li

On Fri, Jan 09, 2026 at 05:57:44PM +0100, Krzysztof Kozlowski wrote:
> Dependencies/merging
> ====================
> 1. First patch is a prerequisite for entire set, so either everything
>    goes via same tree, the further patches wait a cycle or stable tag is
>    shared from DT tree.
> 
> 2. The last media patch depends on my earlier cleanup.
> 
> Changes in v3:
> - New patch: cdx: Use mutex guard to simplify error handling
> - Collect tags
> - Link to v2: https://patch.msgid.link/20260106-of-for-each-compatible-scoped-v2-0-05eb948d91f2@oss.qualcomm.com
> 
> Changes in v2:
> - Update also scripts/dtc/dt-extract-compatibles (Rob)
> - Collect tags
> - Link to v1: https://patch.msgid.link/20260105-of-for-each-compatible-scoped-v1-0-24e99c177164@oss.qualcomm.com
> 
> Description
> ===========
> Simplify for_each_compatible_node() users with a new helper -
> for_each_compatible_node_scoped().
> 
> Best regards,
> Krzysztof
> 
> ---
> Krzysztof Kozlowski (12):
>       of: Add for_each_compatible_node_scoped() helper
>       ARM: at91: Simplify with scoped for each OF child loop
>       ARM: exynos: Simplify with scoped for each OF child loop
>       powerpc/fsp2: Simplify with scoped for each OF child loop
>       powerpc/wii: Simplify with scoped for each OF child loop
>       cdx: Simplify with scoped for each OF child loop
>       cdx: Use mutex guard to simplify error handling
>       clk: imx: imx27: Simplify with scoped for each OF child loop
>       clk: imx: imx31: Simplify with scoped for each OF child loop
>       dmaengine: fsl_raid: Simplify with scoped for each OF child loop
>       cpufreq: s5pv210: Simplify with scoped for each OF child loop
>       media: samsung: exynos4-is: Simplify with scoped for each OF child loop

I applied all but the last patch which did not apply for me. Send it 
next cycle.

Rob

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

end of thread, other threads:[~2026-01-29 17:14 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09 16:57 [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Krzysztof Kozlowski
2026-01-09 16:57 ` [PATCH v3 01/12] of: Add for_each_compatible_node_scoped() helper Krzysztof Kozlowski
2026-01-09 16:57 ` [PATCH v3 02/12] ARM: at91: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-10 15:09   ` Claudiu Beznea
2026-01-09 16:57 ` [PATCH v3 03/12] ARM: exynos: " Krzysztof Kozlowski
2026-01-09 16:57 ` [PATCH v3 04/12] powerpc/fsp2: " Krzysztof Kozlowski
2026-01-09 17:21   ` Christophe Leroy (CS GROUP)
2026-01-09 16:57 ` [PATCH v3 05/12] powerpc/wii: " Krzysztof Kozlowski
2026-01-09 17:22   ` Christophe Leroy (CS GROUP)
2026-01-09 16:57 ` [PATCH v3 06/12] cdx: " Krzysztof Kozlowski
2026-01-12 12:48   ` Jonathan Cameron
2026-01-09 16:57 ` [PATCH v3 07/12] cdx: Use mutex guard to simplify error handling Krzysztof Kozlowski
2026-01-12 12:48   ` Jonathan Cameron
2026-01-09 16:57 ` [PATCH v3 08/12] clk: imx: imx27: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-09 16:57 ` [PATCH v3 09/12] clk: imx: imx31: " Krzysztof Kozlowski
2026-01-09 16:57 ` [PATCH v3 10/12] dmaengine: fsl_raid: " Krzysztof Kozlowski
2026-01-09 16:57 ` [PATCH v3 11/12] cpufreq: s5pv210: " Krzysztof Kozlowski
2026-01-09 16:57 ` [PATCH v3 12/12] media: samsung: exynos4-is: " Krzysztof Kozlowski
2026-01-29 17:14 ` [PATCH v3 00/12] of/treewide: Simplify with for_each_compatible_node_scoped() Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox