summaryrefslogtreecommitdiff
path: root/include/dm/read.h
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@st.com>2017-07-18 11:57:08 +0200
committerMarek Vasut <marex@denx.de>2017-07-28 23:34:08 +0200
commit642346ae269c3c5c54cf7e15c426c42f4df031da (patch)
tree2ca4b749f8fe2965314dcde27c388c7eb4ce5ff2 /include/dm/read.h
parent82a8a669b4f7159f1f3c3251c2fcb36965896290 (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/read.h')
-rw-r--r--include/dm/read.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/dm/read.h b/include/dm/read.h
index b86a2f5fec..d09b04d110 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -209,6 +209,24 @@ int dev_read_phandle_with_args(struct udevice *dev, const char *list_name,
struct ofnode_phandle_args *out_args);
/**
+ * dev_count_phandle_with_args() - Return phandle number in a list
+ *
+ * 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.
+ *
+ *
+ * @dev: device whose node containing a list
+ * @list_name: property name that contains a list
+ * @cells_name: property name that specifies phandles' arguments count
+ * @Returns number of phandle found on success, on error returns appropriate
+ * errno value.
+ */
+
+int dev_count_phandle_with_args(struct udevice *dev, const char *list_name,
+ const char *cells_name);
+
+/**
* dev_read_addr_cells() - Get the number of address cells for a device's node
*
* This walks back up the tree to find the closest #address-cells property
@@ -416,6 +434,13 @@ static inline int dev_read_phandle_with_args(struct udevice *dev,
out_args);
}
+static inline int dev_count_phandle_with_args(struct udevice *dev,
+ const char *list_name, const char *cells_name)
+{
+ return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
+ cells_name);
+}
+
static inline int dev_read_addr_cells(struct udevice *dev)
{
/* NOTE: this call should walk up the parent stack */