dm: core: fix member name in ofnode_union documentation
[oweals/u-boot.git] / include / dm / ofnode.h
index 966ca9309a3c776fbeb1385852b681b01f7f9ca3..8b9932a569ce5a33a813f3bdb11ed2fc880c210b 100644 (file)
@@ -45,7 +45,7 @@ struct resource;
  * the DT.
  *
  * @np: Pointer to device node, used for live tree
- * @flat_ptr: Pointer into flat device tree, used for flat tree. Note that this
+ * @of_offset: Pointer into flat device tree, used for flat tree. Note that this
  *     is not a really a pointer to a node: it is an offset value. See above.
  */
 typedef union ofnode_union {
@@ -434,6 +434,23 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
                                   int index,
                                   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
  *
@@ -608,5 +625,31 @@ int ofnode_read_simple_size_cells(ofnode node);
 bool ofnode_pre_reloc(ofnode node);
 
 int ofnode_read_resource(ofnode node, uint index, struct resource *res);
+int ofnode_read_resource_byname(ofnode node, const char *name,
+                               struct resource *res);
+
+/**
+ * ofnode_for_each_subnode() - iterate over all subnodes of a parent
+ *
+ * @node:       child node (ofnode, lvalue)
+ * @parent:     parent node (ofnode)
+ *
+ * This is a wrapper around a for loop and is used like so:
+ *
+ *     ofnode node;
+ *
+ *     ofnode_for_each_subnode(node, parent) {
+ *             Use node
+ *             ...
+ *     }
+ *
+ * Note that this is implemented as a macro and @node is used as
+ * iterator in the loop. The parent variable can be a constant or even a
+ * literal.
+ */
+#define ofnode_for_each_subnode(node, parent) \
+       for (node = ofnode_first_subnode(parent); \
+            ofnode_valid(node); \
+            node = ofnode_next_subnode(node))
 
 #endif