Hi Biju, On Fri, 31 Jan 2025 at 10:48, Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote: > There are lot of drivers using of_get_child_by_name() followed > by of_device_is_available() to check the child node availabilty > by name for a given parent. Provide a helper for these users to > simplify the code. > > Suggested-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> > Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx> Thanks for your patch! > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -824,6 +824,34 @@ struct device_node *of_get_child_by_name(const struct device_node *node, > } > EXPORT_SYMBOL(of_get_child_by_name); > > +/** > + * of_get_available_child_by_name - Find the child node availabilty by name for a given parent available child node? > + * @node: parent node > + * @name: child name to look for. > + * > + * This function looks for child node for given matching name and check the checks > + * device availability for use. device's > + * > + * Return: A node pointer if found, with refcount incremented, use > + * of_node_put() on it when done. > + * Returns NULL if node is not found. > + */ > +struct device_node *of_get_available_child_by_name(const struct device_node *node, > + const char *name) > +{ > + struct device_node *child; > + > + for_each_child_of_node(node, child) > + if (of_node_name_eq(child, name)) > + break; child = of_get_child_by_name(node, name); > + > + if (child && !of_device_is_available(child)) > + of_node_put(child); Missing return NULL. > + > + return child; > +} > +EXPORT_SYMBOL(of_get_available_child_by_name); > + > struct device_node *__of_find_node_by_path(const struct device_node *parent, > const char *path) > { Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds