Skip to content

Commit

Permalink
of: Add for_each_endpoint_of_node helper macro
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Philipp Zabel committed Feb 23, 2015
1 parent f033c0b commit ee89059
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/linux/of_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ struct of_endpoint {
const struct device_node *local_node;
};

/**
* for_each_endpoint_of_node - iterate over every endpoint in a device node
* @parent: parent device node containing ports and endpoints
* @child: loop variable pointing to the current endpoint node
*
* When breaking out of the loop, of_node_put(child) has to be called manually.
*/
#define for_each_endpoint_of_node(parent, child) \
for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \
child = of_graph_get_next_endpoint(parent, child))

#ifdef CONFIG_OF
int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint);
Expand Down

0 comments on commit ee89059

Please sign in to comment.