summaryrefslogtreecommitdiff
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@linaro.org>2015-03-29 08:59:58 +0100
committerGrant Likely <grant.likely@linaro.org>2015-03-29 08:59:58 +0100
commita2166ca5f3204794e8b59f01c93a0f1564e3e138 (patch)
treeb667828c308ffd79f1b2bd8fc1da95e43dfef4e3 /drivers/of/base.c
parent37791b6fbe7ab772020e714d34515f144fa981a0 (diff)
parent01218bf14ee60d4a2d6c667ebdbba3ae9a7a1d66 (diff)
Merge remote-tracking branch 'robh/for-next' into devicetree/next
Conflicts: drivers/of/unittest.c
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 8f165b112e03..69566b6a876d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2083,13 +2083,44 @@ int of_graph_parse_endpoint(const struct device_node *node,
EXPORT_SYMBOL(of_graph_parse_endpoint);
/**
+ * of_graph_get_port_by_id() - get the port matching a given id
+ * @parent: pointer to the parent device node
+ * @id: id of the port
+ *
+ * Return: A 'port' node pointer with refcount incremented. The caller
+ * has to use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id)
+{
+ struct device_node *node, *port;
+
+ node = of_get_child_by_name(parent, "ports");
+ if (node)
+ parent = node;
+
+ for_each_child_of_node(parent, port) {
+ u32 port_id = 0;
+
+ if (of_node_cmp(port->name, "port") != 0)
+ continue;
+ of_property_read_u32(port, "reg", &port_id);
+ if (id == port_id)
+ break;
+ }
+
+ of_node_put(node);
+
+ return port;
+}
+EXPORT_SYMBOL(of_graph_get_port_by_id);
+
+/**
* of_graph_get_next_endpoint() - get next endpoint node
* @parent: pointer to the parent device node
* @prev: previous endpoint node, or NULL to get first
*
* Return: An 'endpoint' node pointer with refcount incremented. Refcount
- * of the passed @prev node is not decremented, the caller have to use
- * of_node_put() on it when done.
+ * of the passed @prev node is decremented.
*/
struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
struct device_node *prev)
@@ -2125,12 +2156,6 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n",
__func__, prev->full_name))
return NULL;
-
- /*
- * Avoid dropping prev node refcount to 0 when getting the next
- * child below.
- */
- of_node_get(prev);
}
while (1) {