From patchwork Wed Mar 11 06:50:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 243491 List-Id: U-Boot discussion From: chunfeng.yun at mediatek.com (Chunfeng Yun) Date: Wed, 11 Mar 2020 14:50:41 +0800 Subject: [PATCH 4/8] dm: core: Add function to get child count of ofnode In-Reply-To: <1583909445-27444-1-git-send-email-chunfeng.yun@mediatek.com> References: <1583909445-27444-1-git-send-email-chunfeng.yun@mediatek.com> Message-ID: <1583909445-27444-5-git-send-email-chunfeng.yun@mediatek.com> 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) +{ + ofnode child; + int num = 0; + + ofnode_for_each_subnode(child, parent) + num++; + + return num; +} + /** * ofnode_translate_address() - Translate a device-tree address *