From: Stephen Rothwell Date: Wed, 3 Oct 2012 05:12:10 +0000 (+1000) Subject: Merge remote-tracking branch 'dt-rh/for-next' X-Git-Tag: next-20121003~23 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e2cc471e025ba9bb18c0309b5bd28266cbce4bc3;p=karo-tx-linux.git Merge remote-tracking branch 'dt-rh/for-next' Conflicts: drivers/of/base.c include/linux/of.h --- e2cc471e025ba9bb18c0309b5bd28266cbce4bc3 diff --cc drivers/of/base.c index 4a8d46ffb0ec,e2e813624df5..38892a9f5400 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@@ -363,33 -363,29 +363,56 @@@ struct device_node *of_get_next_child(c } EXPORT_SYMBOL(of_get_next_child); +/** + * of_get_next_available_child - Find the next available child node + * @node: parent node + * @prev: previous child of the parent node, or NULL to get first + * + * This function is like of_get_next_child(), except that it + * automatically skips any disabled nodes (i.e. status = "disabled"). + */ +struct device_node *of_get_next_available_child(const struct device_node *node, + struct device_node *prev) +{ + struct device_node *next; + + read_lock(&devtree_lock); + next = prev ? prev->sibling : node->child; + for (; next; next = next->sibling) { + if (!of_device_is_available(next)) + continue; + if (of_node_get(next)) + break; + } + of_node_put(prev); + read_unlock(&devtree_lock); + return next; +} +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 diff --cc include/linux/of.h index 5c7a15836996,fabb524d3d75..72843b72a2b2 --- a/include/linux/of.h +++ b/include/linux/of.h @@@ -190,9 -190,8 +190,11 @@@ extern struct device_node *of_get_paren extern struct device_node *of_get_next_parent(struct device_node *node); extern struct device_node *of_get_next_child(const struct device_node *node, struct device_node *prev); +extern struct device_node *of_get_next_available_child( + const struct device_node *node, struct device_node *prev); + + extern struct device_node *of_get_child_by_name(const struct device_node *node, + const char *name); #define for_each_child_of_node(parent, child) \ for (child = of_get_next_child(parent, NULL); child != NULL; \ child = of_get_next_child(parent, child))