Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH 1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop
@ 2026-01-02 12:50 Krzysztof Kozlowski
  2026-01-02 12:50 ` [PATCH 2/2] bus: stm32_firewall: " Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-02 12:50 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Gatien Chevallier,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: 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>
---
 drivers/bus/qcom-ebi2.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/qcom-ebi2.c b/drivers/bus/qcom-ebi2.c
index c1fef1b4bd89..be8166565e7c 100644
--- a/drivers/bus/qcom-ebi2.c
+++ b/drivers/bus/qcom-ebi2.c
@@ -292,7 +292,6 @@ static void qcom_ebi2_setup_chipselect(struct device_node *np,
 static int qcom_ebi2_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
 	struct device *dev = &pdev->dev;
 	struct resource *res;
 	void __iomem *ebi2_base;
@@ -348,15 +347,13 @@ static int qcom_ebi2_probe(struct platform_device *pdev)
 	writel(val, ebi2_base);
 
 	/* Walk over the child nodes and see what chipselects we use */
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		u32 csindex;
 
 		/* Figure out the chipselect */
 		ret = of_property_read_u32(child, "reg", &csindex);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ret;
-		}
 
 		if (csindex > 5) {
 			dev_err(dev,
-- 
2.51.0


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

* [PATCH 2/2] bus: stm32_firewall: Simplify with scoped for each OF child loop
  2026-01-02 12:50 [PATCH 1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-02 12:50 ` Krzysztof Kozlowski
  2026-01-02 14:04   ` Konrad Dybcio
  2026-01-05 10:49   ` Jonathan Cameron
  2026-01-02 14:04 ` [PATCH 1/2] bus: qcom-ebi2: " Konrad Dybcio
  2026-01-03  4:34 ` (subset) " Bjorn Andersson
  2 siblings, 2 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-02 12:50 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Gatien Chevallier,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: 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>
---
 drivers/bus/stm32_firewall.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
index 2fc9761dadec..fae881cea9a0 100644
--- a/drivers/bus/stm32_firewall.c
+++ b/drivers/bus/stm32_firewall.c
@@ -241,7 +241,6 @@ EXPORT_SYMBOL_GPL(stm32_firewall_controller_unregister);
 int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_controller)
 {
 	struct stm32_firewall *firewalls;
-	struct device_node *child;
 	struct device *parent;
 	unsigned int i;
 	int len;
@@ -251,25 +250,20 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
 
 	dev_dbg(parent, "Populating %s system bus\n", dev_name(firewall_controller->dev));
 
-	for_each_available_child_of_node(dev_of_node(parent), child) {
+	for_each_available_child_of_node_scoped(dev_of_node(parent), child) {
 		/* The access-controllers property is mandatory for firewall bus devices */
 		len = of_count_phandle_with_args(child, "access-controllers",
 						 "#access-controller-cells");
-		if (len <= 0) {
-			of_node_put(child);
+		if (len <= 0)
 			return -EINVAL;
-		}
 
 		firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
-		if (!firewalls) {
-			of_node_put(child);
+		if (!firewalls)
 			return -ENOMEM;
-		}
 
 		err = stm32_firewall_get_firewall(child, firewalls, (unsigned int)len);
 		if (err) {
 			kfree(firewalls);
-			of_node_put(child);
 			return err;
 		}
 
-- 
2.51.0


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

* Re: [PATCH 1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop
  2026-01-02 12:50 [PATCH 1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
  2026-01-02 12:50 ` [PATCH 2/2] bus: stm32_firewall: " Krzysztof Kozlowski
@ 2026-01-02 14:04 ` Konrad Dybcio
  2026-01-03  4:34 ` (subset) " Bjorn Andersson
  2 siblings, 0 replies; 6+ messages in thread
From: Konrad Dybcio @ 2026-01-02 14:04 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Bjorn Andersson, Konrad Dybcio,
	Gatien Chevallier, Maxime Coquelin, Alexandre Torgue,
	linux-arm-msm, linux-kernel, linux-stm32, linux-arm-kernel

On 1/2/26 1:50 PM, Krzysztof Kozlowski 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: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

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

* Re: [PATCH 2/2] bus: stm32_firewall: Simplify with scoped for each OF child loop
  2026-01-02 12:50 ` [PATCH 2/2] bus: stm32_firewall: " Krzysztof Kozlowski
@ 2026-01-02 14:04   ` Konrad Dybcio
  2026-01-05 10:49   ` Jonathan Cameron
  1 sibling, 0 replies; 6+ messages in thread
From: Konrad Dybcio @ 2026-01-02 14:04 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Bjorn Andersson, Konrad Dybcio,
	Gatien Chevallier, Maxime Coquelin, Alexandre Torgue,
	linux-arm-msm, linux-kernel, linux-stm32, linux-arm-kernel

On 1/2/26 1:50 PM, Krzysztof Kozlowski 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: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

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

* Re: (subset) [PATCH 1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop
  2026-01-02 12:50 [PATCH 1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
  2026-01-02 12:50 ` [PATCH 2/2] bus: stm32_firewall: " Krzysztof Kozlowski
  2026-01-02 14:04 ` [PATCH 1/2] bus: qcom-ebi2: " Konrad Dybcio
@ 2026-01-03  4:34 ` Bjorn Andersson
  2 siblings, 0 replies; 6+ messages in thread
From: Bjorn Andersson @ 2026-01-03  4:34 UTC (permalink / raw)
  To: Konrad Dybcio, Gatien Chevallier, Maxime Coquelin,
	Alexandre Torgue, linux-arm-msm, linux-kernel, linux-stm32,
	linux-arm-kernel, Krzysztof Kozlowski


On Fri, 02 Jan 2026 13:50:31 +0100, Krzysztof Kozlowski wrote:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> 

Applied, thanks!

[1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop
      commit: 9c252f3c8f390fae4ca09de36c9262a35ae88ace

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

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

* Re: [PATCH 2/2] bus: stm32_firewall: Simplify with scoped for each OF child loop
  2026-01-02 12:50 ` [PATCH 2/2] bus: stm32_firewall: " Krzysztof Kozlowski
  2026-01-02 14:04   ` Konrad Dybcio
@ 2026-01-05 10:49   ` Jonathan Cameron
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-01-05 10:49 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Bjorn Andersson, Konrad Dybcio, Gatien Chevallier,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel

On Fri,  2 Jan 2026 13:50:32 +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>
You could throw a __free() in there for firewalls and avoid having
any cleanup at all to do on error (or good path for that matter).

Otherwise LGTM.

Jonathan

> ---
>  drivers/bus/stm32_firewall.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
> index 2fc9761dadec..fae881cea9a0 100644
> --- a/drivers/bus/stm32_firewall.c
> +++ b/drivers/bus/stm32_firewall.c
> @@ -241,7 +241,6 @@ EXPORT_SYMBOL_GPL(stm32_firewall_controller_unregister);
>  int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_controller)
>  {
>  	struct stm32_firewall *firewalls;
> -	struct device_node *child;
>  	struct device *parent;
>  	unsigned int i;
>  	int len;
> @@ -251,25 +250,20 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>  
>  	dev_dbg(parent, "Populating %s system bus\n", dev_name(firewall_controller->dev));
>  
> -	for_each_available_child_of_node(dev_of_node(parent), child) {
> +	for_each_available_child_of_node_scoped(dev_of_node(parent), child) {
>  		/* The access-controllers property is mandatory for firewall bus devices */
>  		len = of_count_phandle_with_args(child, "access-controllers",
>  						 "#access-controller-cells");
> -		if (len <= 0) {
> -			of_node_put(child);
> +		if (len <= 0)
>  			return -EINVAL;
> -		}
>  
>  		firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
> -		if (!firewalls) {
> -			of_node_put(child);
> +		if (!firewalls)
>  			return -ENOMEM;
> -		}
>  
>  		err = stm32_firewall_get_firewall(child, firewalls, (unsigned int)len);
>  		if (err) {
>  			kfree(firewalls);
> -			of_node_put(child);
>  			return err;
>  		}
>  


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

end of thread, other threads:[~2026-01-05 10:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-02 12:50 [PATCH 1/2] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-02 12:50 ` [PATCH 2/2] bus: stm32_firewall: " Krzysztof Kozlowski
2026-01-02 14:04   ` Konrad Dybcio
2026-01-05 10:49   ` Jonathan Cameron
2026-01-02 14:04 ` [PATCH 1/2] bus: qcom-ebi2: " Konrad Dybcio
2026-01-03  4:34 ` (subset) " Bjorn Andersson

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