mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop
@ 2026-01-05 14:36 Krzysztof Kozlowski
  2026-01-05 14:36 ` [PATCH v2 2/3] bus: stm32_firewall: " Krzysztof Kozlowski
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-05 14:36 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, Konrad Dybcio

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

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

---

Changes in v2:
1. Add Rb tag
---
 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	[flat|nested] 13+ messages in thread

* [PATCH v2 2/3] bus: stm32_firewall: Simplify with scoped for each OF child loop
  2026-01-05 14:36 [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-05 14:36 ` Krzysztof Kozlowski
  2026-01-09 10:33   ` Gatien CHEVALLIER
  2026-01-05 14:37 ` [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-05 14:36 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, Konrad Dybcio

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

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

---

Changes in v2:
1. Add Rb tag
---
 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	[flat|nested] 13+ messages in thread

* [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-01-05 14:36 [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
  2026-01-05 14:36 ` [PATCH v2 2/3] bus: stm32_firewall: " Krzysztof Kozlowski
@ 2026-01-05 14:37 ` Krzysztof Kozlowski
  2026-01-09 10:37   ` Gatien CHEVALLIER
  2026-03-01 14:12   ` Krzysztof Kozlowski
  2026-01-05 14:38 ` [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
  2026-01-06 17:52 ` (subset) " Bjorn Andersson
  3 siblings, 2 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-05 14:37 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, Jonathan Cameron

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

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

---

Changes in v2:
1. New patch
---
 drivers/bus/stm32_firewall.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
index fae881cea9a0..92414a4c7bb1 100644
--- a/drivers/bus/stm32_firewall.c
+++ b/drivers/bus/stm32_firewall.c
@@ -240,7 +240,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 *parent;
 	unsigned int i;
 	int len;
@@ -257,15 +256,14 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
 		if (len <= 0)
 			return -EINVAL;
 
-		firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
+		struct stm32_firewall *firewalls __free(kfree) =
+			kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
 		if (!firewalls)
 			return -ENOMEM;
 
 		err = stm32_firewall_get_firewall(child, firewalls, (unsigned int)len);
-		if (err) {
-			kfree(firewalls);
+		if (err)
 			return err;
-		}
 
 		for (i = 0; i < len; i++) {
 			if (firewall_controller->grant_access(firewall_controller,
@@ -279,8 +277,6 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
 					child->full_name);
 			}
 		}
-
-		kfree(firewalls);
 	}
 
 	return 0;
-- 
2.51.0


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

* Re: [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop
  2026-01-05 14:36 [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
  2026-01-05 14:36 ` [PATCH v2 2/3] bus: stm32_firewall: " Krzysztof Kozlowski
  2026-01-05 14:37 ` [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup Krzysztof Kozlowski
@ 2026-01-05 14:38 ` Krzysztof Kozlowski
  2026-01-06 17:52 ` (subset) " Bjorn Andersson
  3 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-05 14:38 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: Konrad Dybcio

On 05/01/2026 15:36, Krzysztof Kozlowski wrote:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> 
> ---
> 
> Changes in v2:
> 1. Add Rb tag
> ---

Please ignore this one patch #1. I am sorry, this was already applied.

Best regards,
Krzysztof

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

* Re: (subset) [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop
  2026-01-05 14:36 [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2026-01-05 14:38 ` [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
@ 2026-01-06 17:52 ` Bjorn Andersson
  3 siblings, 0 replies; 13+ messages in thread
From: Bjorn Andersson @ 2026-01-06 17:52 UTC (permalink / raw)
  To: Konrad Dybcio, Gatien Chevallier, Maxime Coquelin,
	Alexandre Torgue, linux-arm-msm, linux-kernel, linux-stm32,
	linux-arm-kernel, Krzysztof Kozlowski
  Cc: Konrad Dybcio


On Mon, 05 Jan 2026 15:36:58 +0100, Krzysztof Kozlowski wrote:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> 

Applied, thanks!

[1/3] 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] 13+ messages in thread

* Re: [PATCH v2 2/3] bus: stm32_firewall: Simplify with scoped for each OF child loop
  2026-01-05 14:36 ` [PATCH v2 2/3] bus: stm32_firewall: " Krzysztof Kozlowski
@ 2026-01-09 10:33   ` Gatien CHEVALLIER
  0 siblings, 0 replies; 13+ messages in thread
From: Gatien CHEVALLIER @ 2026-01-09 10:33 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Bjorn Andersson, Konrad Dybcio,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: Konrad Dybcio

Hello,

Tested on stm32mp135f-dk, so:

Tested-by: Gatien Chevallier <gatien.chevallier@foss.st.com>

Thank you

On 1/5/26 15:36, Krzysztof Kozlowski wrote:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> 
> ---
> 
> Changes in v2:
> 1. Add Rb tag
> ---
>   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] 13+ messages in thread

* Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-01-05 14:37 ` [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup Krzysztof Kozlowski
@ 2026-01-09 10:37   ` Gatien CHEVALLIER
  2026-01-09 11:55     ` Krzysztof Kozlowski
  2026-03-01 14:12   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 13+ messages in thread
From: Gatien CHEVALLIER @ 2026-01-09 10:37 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Bjorn Andersson, Konrad Dybcio,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: Jonathan Cameron

On 1/5/26 15:37, Krzysztof Kozlowski wrote:
> Allocate the memory with scoped/cleanup.h to reduce error handling and
> make the code a bit simpler.
> 
> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> 
> ---
> 
> Changes in v2:
> 1. New patch
> ---
>   drivers/bus/stm32_firewall.c | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
> index fae881cea9a0..92414a4c7bb1 100644
> --- a/drivers/bus/stm32_firewall.c
> +++ b/drivers/bus/stm32_firewall.c
> @@ -240,7 +240,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 *parent;
>   	unsigned int i;
>   	int len;
> @@ -257,15 +256,14 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>   		if (len <= 0)
>   			return -EINVAL;
>   
> -		firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
> +		struct stm32_firewall *firewalls __free(kfree) =
> +			kcalloc(len, sizeof(*firewalls), GFP_KERNEL);

Hello,

I'd prefer to keep declarations separated.

Otherwise:

Tested-by: Gatien Chevallier <gatien.chevallier@foss.st.com>

Thank you,

Gatien

>   		if (!firewalls)
>   			return -ENOMEM;
>   
>   		err = stm32_firewall_get_firewall(child, firewalls, (unsigned int)len);
> -		if (err) {
> -			kfree(firewalls);
> +		if (err)
>   			return err;
> -		}
>   
>   		for (i = 0; i < len; i++) {
>   			if (firewall_controller->grant_access(firewall_controller,
> @@ -279,8 +277,6 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>   					child->full_name);
>   			}
>   		}
> -
> -		kfree(firewalls);
>   	}
>   
>   	return 0;


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

* Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-01-09 10:37   ` Gatien CHEVALLIER
@ 2026-01-09 11:55     ` Krzysztof Kozlowski
  2026-01-09 12:34       ` Gatien CHEVALLIER
  0 siblings, 1 reply; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 11:55 UTC (permalink / raw)
  To: Gatien CHEVALLIER, Bjorn Andersson, Konrad Dybcio,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: Jonathan Cameron

On 09/01/2026 11:37, Gatien CHEVALLIER wrote:
> On 1/5/26 15:37, Krzysztof Kozlowski wrote:
>> Allocate the memory with scoped/cleanup.h to reduce error handling and
>> make the code a bit simpler.
>>
>> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>>
>> ---
>>
>> Changes in v2:
>> 1. New patch
>> ---
>>   drivers/bus/stm32_firewall.c | 10 +++-------
>>   1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
>> index fae881cea9a0..92414a4c7bb1 100644
>> --- a/drivers/bus/stm32_firewall.c
>> +++ b/drivers/bus/stm32_firewall.c
>> @@ -240,7 +240,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 *parent;
>>   	unsigned int i;
>>   	int len;
>> @@ -257,15 +256,14 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>>   		if (len <= 0)
>>   			return -EINVAL;
>>   
>> -		firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
>> +		struct stm32_firewall *firewalls __free(kfree) =
>> +			kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
> 
> Hello,
> 
> I'd prefer to keep declarations separated.

Separated how? This is the coding style of cleanup (which is quite
explicit around other styles)? Or you meant one line without wrapping?

> 
> Otherwise:
> 
> Tested-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
> 



Best regards,
Krzysztof

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

* Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-01-09 11:55     ` Krzysztof Kozlowski
@ 2026-01-09 12:34       ` Gatien CHEVALLIER
  2026-01-09 15:20         ` Krzysztof Kozlowski
  0 siblings, 1 reply; 13+ messages in thread
From: Gatien CHEVALLIER @ 2026-01-09 12:34 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Bjorn Andersson, Konrad Dybcio,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: Jonathan Cameron



On 1/9/26 12:55, Krzysztof Kozlowski wrote:
> On 09/01/2026 11:37, Gatien CHEVALLIER wrote:
>> On 1/5/26 15:37, Krzysztof Kozlowski wrote:
>>> Allocate the memory with scoped/cleanup.h to reduce error handling and
>>> make the code a bit simpler.
>>>
>>> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>>>
>>> ---
>>>
>>> Changes in v2:
>>> 1. New patch
>>> ---
>>>    drivers/bus/stm32_firewall.c | 10 +++-------
>>>    1 file changed, 3 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
>>> index fae881cea9a0..92414a4c7bb1 100644
>>> --- a/drivers/bus/stm32_firewall.c
>>> +++ b/drivers/bus/stm32_firewall.c
>>> @@ -240,7 +240,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 *parent;
>>>    	unsigned int i;
>>>    	int len;
>>> @@ -257,15 +256,14 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>>>    		if (len <= 0)
>>>    			return -EINVAL;
>>>    
>>> -		firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
>>> +		struct stm32_firewall *firewalls __free(kfree) =
>>> +			kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
>>
>> Hello,
>>
>> I'd prefer to keep declarations separated.
> 
> Separated how? This is the coding style of cleanup (which is quite
> explicit around other styles)? Or you meant one line without wrapping?
> 

I found odd to declare and assign a variable mid-loop but I found
multiple occurrences of the same kind of cleanup.

You can drop my comment, I'm fine with how it is. Thanks for the
cleanup.

>>
>> Otherwise:
>>
>> Tested-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
>>
> 
> 
> 
> Best regards,
> Krzysztof


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

* Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-01-09 12:34       ` Gatien CHEVALLIER
@ 2026-01-09 15:20         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-09 15:20 UTC (permalink / raw)
  To: Gatien CHEVALLIER, Bjorn Andersson, Konrad Dybcio,
	Maxime Coquelin, Alexandre Torgue, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: Jonathan Cameron

On 09/01/2026 13:34, Gatien CHEVALLIER wrote:
> 
> 
> On 1/9/26 12:55, Krzysztof Kozlowski wrote:
>> On 09/01/2026 11:37, Gatien CHEVALLIER wrote:
>>> On 1/5/26 15:37, Krzysztof Kozlowski wrote:
>>>> Allocate the memory with scoped/cleanup.h to reduce error handling and
>>>> make the code a bit simpler.
>>>>
>>>> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>>>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>>>>
>>>> ---
>>>>
>>>> Changes in v2:
>>>> 1. New patch
>>>> ---
>>>>    drivers/bus/stm32_firewall.c | 10 +++-------
>>>>    1 file changed, 3 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/drivers/bus/stm32_firewall.c b/drivers/bus/stm32_firewall.c
>>>> index fae881cea9a0..92414a4c7bb1 100644
>>>> --- a/drivers/bus/stm32_firewall.c
>>>> +++ b/drivers/bus/stm32_firewall.c
>>>> @@ -240,7 +240,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 *parent;
>>>>    	unsigned int i;
>>>>    	int len;
>>>> @@ -257,15 +256,14 @@ int stm32_firewall_populate_bus(struct stm32_firewall_controller *firewall_contr
>>>>    		if (len <= 0)
>>>>    			return -EINVAL;
>>>>    
>>>> -		firewalls = kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
>>>> +		struct stm32_firewall *firewalls __free(kfree) =
>>>> +			kcalloc(len, sizeof(*firewalls), GFP_KERNEL);
>>>
>>> Hello,
>>>
>>> I'd prefer to keep declarations separated.
>>
>> Separated how? This is the coding style of cleanup (which is quite
>> explicit around other styles)? Or you meant one line without wrapping?
>>
> 
> I found odd to declare and assign a variable mid-loop but I found
> multiple occurrences of the same kind of cleanup.
> 
> You can drop my comment, I'm fine with how it is. Thanks for the
> cleanup.
> 

Sure, just to let you know - it is fair to reject cleanup.h entirely for
code you maintain (like netdev did). I only disagree with sort of
semi-cleanup.h without following its declaration and initialization
rules, because it is more error-prone, leads to bugs and often does not
make the code easier to read/simpler.

Best regards,
Krzysztof

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

* Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-01-05 14:37 ` [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup Krzysztof Kozlowski
  2026-01-09 10:37   ` Gatien CHEVALLIER
@ 2026-03-01 14:12   ` Krzysztof Kozlowski
  2026-03-02  8:15     ` Alexandre TORGUE
  2026-03-10  9:04     ` Alexandre TORGUE
  1 sibling, 2 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-01 14:12 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: Jonathan Cameron

On 05/01/2026 15:37, Krzysztof Kozlowski wrote:
> Allocate the memory with scoped/cleanup.h to reduce error handling and
> make the code a bit simpler.
> 
> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> 
> ---
> 
> Changes in v2:
> 1. New patch
> ---
>  drivers/bus/stm32_firewall.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)

Is anyone picking up patches for stm32?

Best regards,
Krzysztof

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

* Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-03-01 14:12   ` Krzysztof Kozlowski
@ 2026-03-02  8:15     ` Alexandre TORGUE
  2026-03-10  9:04     ` Alexandre TORGUE
  1 sibling, 0 replies; 13+ messages in thread
From: Alexandre TORGUE @ 2026-03-02  8:15 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Bjorn Andersson, Konrad Dybcio,
	Gatien Chevallier, Maxime Coquelin, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: Jonathan Cameron



On 3/1/26 15:12, Krzysztof Kozlowski wrote:
> On 05/01/2026 15:37, Krzysztof Kozlowski wrote:
>> Allocate the memory with scoped/cleanup.h to reduce error handling and
>> make the code a bit simpler.
>>
>> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>>
>> ---
>>
>> Changes in v2:
>> 1. New patch
>> ---
>>   drivers/bus/stm32_firewall.c | 10 +++-------
>>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> Is anyone picking up patches for stm32?

I will.

> 
> Best regards,
> Krzysztof


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

* Re: [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup
  2026-03-01 14:12   ` Krzysztof Kozlowski
  2026-03-02  8:15     ` Alexandre TORGUE
@ 2026-03-10  9:04     ` Alexandre TORGUE
  1 sibling, 0 replies; 13+ messages in thread
From: Alexandre TORGUE @ 2026-03-10  9:04 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Bjorn Andersson, Konrad Dybcio,
	Gatien Chevallier, Maxime Coquelin, linux-arm-msm, linux-kernel,
	linux-stm32, linux-arm-kernel
  Cc: Jonathan Cameron



On 3/1/26 15:12, Krzysztof Kozlowski wrote:
> On 05/01/2026 15:37, Krzysztof Kozlowski wrote:
>> Allocate the memory with scoped/cleanup.h to reduce error handling and
>> make the code a bit simpler.
>>
>> Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>>
>> ---
>>
>> Changes in v2:
>> 1. New patch
>> ---
>>   drivers/bus/stm32_firewall.c | 10 +++-------
>>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> Is anyone picking up patches for stm32?


Applied on stm32-next.

regards
Alex

> 
> Best regards,
> Krzysztof


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

end of thread, other threads:[~2026-03-10  9:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-05 14:36 [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-05 14:36 ` [PATCH v2 2/3] bus: stm32_firewall: " Krzysztof Kozlowski
2026-01-09 10:33   ` Gatien CHEVALLIER
2026-01-05 14:37 ` [PATCH v2 3/3] bus: stm32_firewall: Use scoped allocation to simplify cleanup Krzysztof Kozlowski
2026-01-09 10:37   ` Gatien CHEVALLIER
2026-01-09 11:55     ` Krzysztof Kozlowski
2026-01-09 12:34       ` Gatien CHEVALLIER
2026-01-09 15:20         ` Krzysztof Kozlowski
2026-03-01 14:12   ` Krzysztof Kozlowski
2026-03-02  8:15     ` Alexandre TORGUE
2026-03-10  9:04     ` Alexandre TORGUE
2026-01-05 14:38 ` [PATCH v2 1/3] bus: qcom-ebi2: Simplify with scoped for each OF child loop Krzysztof Kozlowski
2026-01-06 17:52 ` (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

all inboxes | Powered by JetHome®