summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/core/ofnode.c12
-rw-r--r--include/dm/ofnode.h11
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index b2b02e4abf..29375397e0 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -729,3 +729,15 @@ int ofnode_device_is_compatible(ofnode node, const char *compat)
ofnode_to_offset(node),
compat);
}
+
+ofnode ofnode_by_compatible(ofnode from, const char *compat)
+{
+ if (of_live_active()) {
+ return np_to_ofnode(of_find_compatible_node(
+ (struct device_node *)ofnode_to_np(from), NULL,
+ compat));
+ } else {
+ return offset_to_ofnode(fdt_node_offset_by_compatible(
+ gd->fdt_blob, ofnode_to_offset(from), compat));
+ }
+}
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 61c42311f8..cd08a7e4d0 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -679,6 +679,17 @@ int ofnode_read_resource_byname(ofnode node, const char *name,
struct resource *res);
/**
+ * ofnode_by_compatible() - Find the next compatible node
+ *
+ * Find the next node after @from that is compatible with @compat
+ *
+ * @from: ofnode to start from (use ofnode_null() to start at the beginning)
+ * @compat: Compatible string to match
+ * @return ofnode found, or ofnode_null() if none
+ */
+ofnode ofnode_by_compatible(ofnode from, const char *compat);
+
+/**
* ofnode_for_each_subnode() - iterate over all subnodes of a parent
*
* @node: child node (ofnode, lvalue)