From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chunfeng Yun Date: Thu, 12 Mar 2020 14:24:54 +0800 Subject: [PATCH 4/8] dm: core: Add function to get child count of ofnode In-Reply-To: References: <1583909445-27444-1-git-send-email-chunfeng.yun@mediatek.com> <1583909445-27444-5-git-send-email-chunfeng.yun@mediatek.com> Message-ID: <1583994294.25913.4.camel@mhfsdcap03> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, 2020-03-11 at 06:17 -0600, Simon Glass wrote: > Hi Chunfeng, > > On Wed, 11 Mar 2020 at 01:01, Chunfeng Yun wrote: > > > > This patch add a function used to get the child count of > > a ofnode > > > > Signed-off-by: Chunfeng Yun > > --- > > 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. Ok > > > +{ > > + 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 Will add it. Thanks > > Regards, > Simon