Message ID | 1583909445-27444-5-git-send-email-chunfeng.yun@mediatek.com |
---|---|
State | New |
Headers | show |
Series | Add support for MediaTek xHCI host controller | expand |
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
On Wed, 2020-03-11 at 06:17 -0600, Simon Glass wrote: > 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. 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
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) +{ + ofnode child; + int num = 0; + + ofnode_for_each_subnode(child, parent) + num++; + + return num; +} + /** * ofnode_translate_address() - Translate a device-tree address *
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(+)