Re: [PATCH -next] net: dsa: Simplify with scoped for each OF child loop

From: Jinjie Ruan
Date: Wed Aug 21 2024 - 22:07:43 EST




On 2024/8/22 8:18, Jakub Kicinski wrote:
> On Tue, 20 Aug 2024 14:58:04 +0800 Jinjie Ruan wrote:
>> Use scoped for_each_available_child_of_node_scoped() when iterating over
>> device nodes to make code a bit simpler.
>
> Could you add more info here that confirms this works with gotos?
> I don't recall the details but I thought sometimes the scoped
> constructs don't do well with gotos. I checked 5 random uses
> of this loop and 4 of them didn't have gotos.

Hi, Jakub

>From what I understand, for_each_available_child_of_node_scoped() is not
related to gotos, it only let the iterating child node self-declared and
automatic release, so the of_node_put(iterating_child_node) can be removed.

For example, the following use case has goto and use this macro:

Link:
https://lore.kernel.org/all/20240813-b4-cleanup-h-of-node-put-other-v1-6-cfb67323a95c@xxxxxxxxxx/