[PATCH 4/8] dm: core: Add function to get child count of ofnode

Simon Glass sjg at chromium.org
Wed Mar 11 13:17:56 CET 2020


Hi Chunfeng,

On Wed, 11 Mar 2020 at 01:01, Chunfeng Yun <chunfeng.yun at mediatek.com> wrote:
>
> This patch add a function used to get the child count of
> a ofnode
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun at mediatek.com>
> ---
>  include/dm/ofnode.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> index b5a50e8849..b2c0118a36 100644
> --- a/include/dm/ofnode.h
> +++ b/include/dm/ofnode.h
> @@ -793,6 +793,23 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname,
>              ofnode_valid(node); \
>              node = ofnode_next_subnode(node))
>
> +/**
> + * ofnode_get_child_count() - get the child count of a ofnode
> + *
> + * @node:      valid node ot get its child count
> + * @return the count of child subnode
> + */
> +static inline int ofnode_get_child_count(ofnode parent)

Please put this in a C file. There is not really any benefit to be being inline.

> +{
> +       ofnode child;
> +       int num = 0;
> +
> +       ofnode_for_each_subnode(child, parent)
> +               num++;
> +
> +       return num;
> +}
> +
>  /**
>   * ofnode_translate_address() - Translate a device-tree address
>   *
> --
> 2.25.1

Also please add a simple test for your new function to test/dm/ofnode.c

Regards,
Simon


More information about the U-Boot mailing list