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 /include/dm/ofnode.h | |
parent | 82a8a669b4f7159f1f3c3251c2fcb36965896290 (diff) |
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 'include/dm/ofnode.h')
-rw-r--r-- | include/dm/ofnode.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 15ad5199c2f..8eecce59d10 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -433,6 +433,23 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name, struct ofnode_phandle_args *out_args); /** + * ofnode_count_phandle_with_args() - Count number of phandle in a list + * + * This function is useful to count phandles into a list. + * Returns number of phandle on success, on error returns appropriate + * errno value. + * + * @node: device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * @return number of phandle on success, -ENOENT if @list_name does not + * exist, -EINVAL if a phandle was not found, @cells_name could not + * be found. + */ +int ofnode_count_phandle_with_args(ofnode node, const char *list_name, + const char *cells_name); + +/** * ofnode_path() - find a node by full path * * @path: Full path to node, e.g. "/bus/spi@1" |