1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

dm: core: add ofnode_count_phandle_with_args()

This function is usefull to get phandle number contained
in a property list.
For example,  this allows to allocate the right amount
of memory to keep clock's reference contained into the
"clocks" property.

To implement it, either of_count_phandle_with_args() or
fdtdec_parse_phandle_with_args() are used respectively
for live tree and flat tree.
By passing index = -1, these 2 functions returns the
number of phandle contained into the property list.

Add also the dev_count_phandle_with_args() based on
ofnode_count_phandle_with_args()

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Patrice Chotard
2017-07-18 11:57:08 +02:00
committed by Marek Vasut
parent 82a8a669b4
commit 642346ae26
5 changed files with 79 additions and 0 deletions

View File

@@ -313,6 +313,18 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
return 0;
}
int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
const char *cells_name)
{
if (ofnode_is_np(node))
return of_count_phandle_with_args(ofnode_to_np(node),
list_name, cells_name);
else
return fdtdec_parse_phandle_with_args(gd->fdt_blob,
ofnode_to_offset(node), list_name, cells_name,
0, -1, NULL);
}
ofnode ofnode_path(const char *path)
{
if (of_live_active())