summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNeelesh Gupta <neelegup@linux.vnet.ibm.com>2015-02-04 12:29:25 +0530
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-02-11 18:49:29 +1100
commitde8bd4d09310f8307ffd1cee7d0f10b11c44fb60 (patch)
tree180ea7137211ca2b5a9c31c57190d89e6f0b9773 /core
parentcbf0e24e6734ceb52bbefdb02fb9f35f180dad11 (diff)
downloadblackbird-skiboot-de8bd4d09310f8307ffd1cee7d0f10b11c44fb60.tar.gz
blackbird-skiboot-de8bd4d09310f8307ffd1cee7d0f10b11c44fb60.zip
core/device: Function to return child node using name
Add a function dt_find_by_name() that returns the child node if matches the given name, otherwise NULL. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r--core/device.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/device.c b/core/device.c
index 51ddbdbb..09f76d71 100644
--- a/core/device.c
+++ b/core/device.c
@@ -250,6 +250,22 @@ struct dt_node *dt_find_by_path(struct dt_node *root, const char *path)
return root;
}
+struct dt_node *dt_find_by_name(struct dt_node *root, const char *name)
+{
+ struct dt_node *child, *match;
+
+ list_for_each(&root->children, child, list) {
+ if (!strcmp(child->name, name))
+ return child;
+
+ match = dt_find_by_name(child, name);
+ if (match)
+ return match;
+ }
+
+ return NULL;
+}
+
struct dt_node *dt_find_by_phandle(struct dt_node *root, u32 phandle)
{
struct dt_node *node;
OpenPOWER on IntegriCloud