Thread (30 messages) 30 messages, 6 authors, 2011-08-15
STALE5399d
Revisions (3)
  1. rfc current
  2. v2 [diff vs current]
  3. v3 [diff vs current]

[RFC PATCH 01/12] dt: Add of_find_child_node_by_name()

From: Stephen Warren <hidden>
Date: 2011-08-12 22:55:34
Also in: linux-devicetree, linux-tegra, lkml
Subsystem: open firmware and flattened device tree, the rest · Maintainers: Rob Herring, Saravana Kannan, Linus Torvalds

This function retrieves a named child node of a given parent node.

Signed-off-by: Stephen Warren <redacted>
---
 drivers/of/base.c  |   18 ++++++++++++++++++
 include/linux/of.h |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 3ff22e3..7eea9e3 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -388,6 +388,24 @@ struct device_node *of_find_node_by_name(struct device_node *from,
 }
 EXPORT_SYMBOL(of_find_node_by_name);
 
+struct device_node *of_find_child_node_by_name(
+	const struct device_node *parent, const char *name)
+{
+	struct device_node *child;
+
+	read_lock(&devtree_lock);
+
+	for_each_child_of_node(parent, child) {
+		if (!strcmp(child->name, name))
+			break;
+	}
+
+	read_unlock(&devtree_lock);
+
+	return child;
+}
+EXPORT_SYMBOL(of_find_child_node_by_name);
+
 /**
  *	of_find_node_by_type - Find a node by its "device_type" property
  *	@from:	The node to start searching from, or NULL to start searching
diff --git a/include/linux/of.h b/include/linux/of.h
index 9180dc5..032c71b 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -161,6 +161,8 @@ extern struct device_node *of_find_node_by_name(struct device_node *from,
 #define for_each_node_by_name(dn, name) \
 	for (dn = of_find_node_by_name(NULL, name); dn; \
 	     dn = of_find_node_by_name(dn, name))
+extern struct device_node *of_find_child_node_by_name(
+	const struct device_node *node, const char *name);
 extern struct device_node *of_find_node_by_type(struct device_node *from,
 	const char *type);
 #define for_each_node_by_type(dn, type) \
-- 
1.7.0.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help