]> Pileus Git - ~andy/linux/blobdiff - drivers/of/base.c
Merge tag 'dt-for-3.7' of git://sources.calxeda.com/kernel/linux
[~andy/linux] / drivers / of / base.c
index d4a1c9a043e12d3572faefe9a9fd11a1683cdd97..af3b22ac762755b532286ac505fb85ef936ca64b 100644 (file)
@@ -390,6 +390,29 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
 }
 EXPORT_SYMBOL(of_get_next_available_child);
 
+/**
+ *     of_get_child_by_name - Find the child node by name for a given parent
+ *     @node:  parent node
+ *     @name:  child name to look for.
+ *
+ *      This function looks for child node for given matching name
+ *
+ *     Returns a node pointer if found, with refcount incremented, use
+ *     of_node_put() on it when done.
+ *     Returns NULL if node is not found.
+ */
+struct device_node *of_get_child_by_name(const struct device_node *node,
+                               const char *name)
+{
+       struct device_node *child;
+
+       for_each_child_of_node(node, child)
+               if (child->name && (of_node_cmp(child->name, name) == 0))
+                       break;
+       return child;
+}
+EXPORT_SYMBOL(of_get_child_by_name);
+
 /**
  *     of_find_node_by_path - Find a node matching a full OF path
  *     @path:  The full path to match