diff options
author | Patrice Chotard <patrice.chotard@st.com> | 2017-07-18 11:57:08 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2017-07-28 23:34:08 +0200 |
commit | 642346ae269c3c5c54cf7e15c426c42f4df031da (patch) | |
tree | 2ca4b749f8fe2965314dcde27c388c7eb4ce5ff2 /drivers/core | |
parent | 82a8a669b4f7159f1f3c3251c2fcb36965896290 (diff) | |
download | u-boot-642346ae269c3c5c54cf7e15c426c42f4df031da.tar.gz |
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>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/of_access.c | 7 | ||||
-rw-r--r-- | drivers/core/ofnode.c | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c index 2bb23eef885..c31cba7fd6b 100644 --- a/drivers/core/of_access.c +++ b/drivers/core/of_access.c @@ -665,6 +665,13 @@ int of_parse_phandle_with_args(const struct device_node *np, index, out_args); } +int of_count_phandle_with_args(const struct device_node *np, + const char *list_name, const char *cells_name) +{ + return __of_parse_phandle_with_args(np, list_name, cells_name, 0, + -1, NULL); +} + static void of_alias_add(struct alias_prop *ap, struct device_node *np, int id, const char *stem, int stem_len) { diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index fd068b06ef3..5fc77c52a05 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -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()) |