[PATCH] of: base: Add of_get_available_child_by_name()
Biju Das
biju.das.jz at bp.renesas.com
Fri Jan 31 02:07:02 PST 2025
Hi Geert,
Thanks for the feedback.
> -----Original Message-----
> From: Geert Uytterhoeven <geert at linux-m68k.org>
> Sent: 31 January 2025 09:53
> Subject: Re: [PATCH] of: base: Add of_get_available_child_by_name()
>
> Hi Biju,
>
> On Fri, 31 Jan 2025 at 10:48, Biju Das <biju.das.jz at bp.renesas.com> 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 at glider.be>
> > Signed-off-by: Biju Das <biju.das.jz at bp.renesas.com>
>
> 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?
OK, Find the available child node by name for a given parent.
>
> > + * @node: parent node
> > + * @name: child name to look for.
> > + *
> > + * This function looks for child node for given matching name and
> > + check the
>
> checks
OK
>
> > + * device availability for use.
>
> device's
OK.
>
> > + *
> > + * 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);
OK, Will use the above API to avoid duplication.
>
> > +
> > + if (child && !of_device_is_available(child))
> > + of_node_put(child);
>
> Missing return NULL.
OK. Will fix this in next version.
Cheers,
Biju
More information about the Linux-mediatek
mailing list