aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2014-04-14 11:53:25 -0400
committerPhilipp Zabel <p.zabel@pengutronix.de>2015-02-23 05:42:23 -0500
commitee8905963ed0bc9dfc0952dc35e16e233c10e212 (patch)
tree6cfbd1cfb1af19c550a6a3e263f3fb63c625d0d0
parentf033c0bcc53675562200680f4cb4a86710d9fbae (diff)
of: Add for_each_endpoint_of_node helper macro
Note that while of_graph_get_next_endpoint decrements the reference count of the child node passed to it, of_node_put(child) still has to be called manually when breaking out of the loop. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--include/linux/of_graph.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index befef42e015b..e43442efcbe5 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -26,6 +26,17 @@ struct of_endpoint {
26 const struct device_node *local_node; 26 const struct device_node *local_node;
27}; 27};
28 28
29/**
30 * for_each_endpoint_of_node - iterate over every endpoint in a device node
31 * @parent: parent device node containing ports and endpoints
32 * @child: loop variable pointing to the current endpoint node
33 *
34 * When breaking out of the loop, of_node_put(child) has to be called manually.
35 */
36#define for_each_endpoint_of_node(parent, child) \
37 for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
38 child = of_graph_get_next_endpoint(parent, child))
39
29#ifdef CONFIG_OF 40#ifdef CONFIG_OF
30int of_graph_parse_endpoint(const struct device_node *node, 41int of_graph_parse_endpoint(const struct device_node *node,
31 struct of_endpoint *endpoint); 42 struct of_endpoint *endpoint);