Re: [PATCH 1/4] device property: Introduce fwnode_graph_for_each_endpoint_scoped()
From: Andy Shevchenko
Date: Tue Jun 23 2026 - 06:14:54 EST
On Mon, Jun 22, 2026 at 10:30:11AM -0400, Frank.Li@xxxxxxxxxxx wrote:
> From: Frank Li <Frank.Li@xxxxxxx>
>
> Similar to recently propose for_each_child_of_node_scoped() this new
> version of the loop macro instantiates a new local struct fwnode_handle *
> that uses the __free(fwnode_handle) auto cleanup handling so that if a
> reference to a node is held on early exit from the loop the reference will
> be released. If the loop runs to completion, the child pointer will be NULL
> and no action will be taken.
>
> The reason this is useful is that it removes the need for
> fwnode_handle_put() on early loop exits. If there is a need to retain the
Just be consistent with 1-space versus 2-spaces gaps in the same text.
> reference, then return_ptr(child) or no_free_ptr(child) may be used to
> safely disable the auto cleanup.
No objections from me.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
See one nit-pick below.
But you will need driver core maintainers to Ack this.
...
> +#define fwnode_graph_for_each_endpoint_scoped(fwnode, child) \
> + for (struct fwnode_handle *child __free(fwnode_handle) = \
> + fwnode_graph_get_next_endpoint(fwnode, NULL); \
You should follow the existing style, the 'f' in fwnode should be under 'u' in
struct.
> + child; child = fwnode_graph_get_next_endpoint(fwnode, child))
--
With Best Regards,
Andy Shevchenko