dm: core: Add function to get child count of ofnode or device

This patch add function used to get the child count of
a ofnode or a device

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
Reviewed-by: Weijie Gao <weijie.gao@mediatek.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Chunfeng Yun
2020-05-02 11:35:09 +02:00
committed by Marek Vasut
parent c693f212c5
commit 89b84b85e9
4 changed files with 37 additions and 0 deletions

View File

@@ -474,6 +474,17 @@ ofnode ofnode_get_chosen_node(const char *name)
return ofnode_path(prop);
}
int ofnode_get_child_count(ofnode parent)
{
ofnode child;
int num = 0;
ofnode_for_each_subnode(child, parent)
num++;
return num;
}
static int decode_timing_property(ofnode node, const char *name,
struct timing_entry *result)
{

View File

@@ -352,3 +352,8 @@ fdt_addr_t dev_read_addr_pci(const struct udevice *dev)
return addr;
}
int dev_get_child_count(const struct udevice *dev)
{
return ofnode_get_child_count(dev_ofnode(dev));
}