[PATCH v6 02/12] of: base: Add for_each_child_of_node_with_prefix_scoped()
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Wed Sep 4 06:03:47 PDT 2024
On Wed, Sep 04, 2024 at 05:00:04PM +0800, Chen-Yu Tsai wrote:
> There are cases where drivers would go through child device nodes and
> operate on only the ones whose node name starts with a given prefix.
>
> Provide a helper for these users. This will mainly be used in a
> subsequent patch that implements a hardware component prober for I2C
> busses.
...
> +#define for_each_child_of_node_with_prefix_scoped(parent, child, prefix) \
> + for (struct device_node *child __free(device_node) = \
> + of_get_next_child_with_prefix(parent, NULL, prefix); \
> + child != NULL; \
> + child = of_get_next_child_with_prefix(parent, child, prefix))
I'm wondering if we may drop _scoped from day 1. Yeah, probably a bit confusing
as the rest of APIs without that suffix do require reference count handling on
the loop abrupt.
--
With Best Regards,
Andy Shevchenko
More information about the Linux-mediatek
mailing list