@@ -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;
@@ -167,6 +167,9 @@ char *dt_get_path(const struct dt_node *node);
/* Find a node by path */
struct dt_node *dt_find_by_path(struct dt_node *root, const char *path);
+/* Find a child node by name */
+struct dt_node *dt_find_by_name(struct dt_node *root, const char *name);
+
/* Find a node by phandle */
struct dt_node *dt_find_by_phandle(struct dt_node *root, u32 phandle);
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> --- core/device.c | 16 ++++++++++++++++ include/device.h | 3 +++ 2 files changed, 19 insertions(+)