summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-06-11 13:07:13 -0600
committerSimon Glass <sjg@chromium.org>2018-07-09 09:11:00 -0600
commitc60f671b65a8b336c3533fcf0f0ee45dff287ff7 (patch)
treea7c4b6ace5eccc2a9f79d3eac7171b3418741c58 /drivers
parentc98ad4434c1a680915d10e5696e6bee9c81044d5 (diff)
dm: core: Add a way to find an ofnode by compatible string
Add an ofnode_by_compatible() to allow iterating through ofnodes with a given compatible string. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/ofnode.c12
1 files changed, 12 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));
+ }
+}