[PATCH v2 2/3] bus: stm32_firewall: Simplify with scoped for each OF child loop

Gatien CHEVALLIER gatien.chevallier at foss.st.com
Fri Jan 9 02:33:57 PST 2026


Hello,

Tested on stm32mp135f-dk, so:

Tested-by: Gatien Chevallier <gatien.chevallier at 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 at oss.qualcomm.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at 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;
>   		}
>   




More information about the linux-arm-kernel mailing list