From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Subject: [PATCH 6/7] of_graph: add of_graph_get_top_port() Date: Fri, 24 Jun 2016 02:33:53 +0000 Message-ID: <877fdfxqx7.wl%kuninori.morimoto.gx@renesas.com> References: <87fus3xr2q.wl%kuninori.morimoto.gx@renesas.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="US-ASCII" Return-path: In-Reply-To: <87fus3xr2q.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Rob Herring , Mark Brown , Mark Brown , Laurent , Guennadi , Grant Likely , Frank Rowand Cc: Linux-Kernel , Linux-DT , Linux-ALSA List-Id: devicetree@vger.kernel.org From: Kuninori Morimoto driver want to get top level of port[s] node. This patch adds of_graph_get_top_port() for this purpose Signed-off-by: Kuninori Morimoto --- drivers/of/base.c | 24 ++++++++++++++++++++++++ include/linux/of_graph.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index 283cfbb..e220a16 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2225,6 +2225,30 @@ struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id) EXPORT_SYMBOL(of_graph_get_port_by_id); /** + * of_graph_get_top_port() - get the top port node + * @dev: pointer to the device + * + * 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_top_port(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct device_node *node; + + node = of_get_child_by_name(np, "ports"); + if (node) + return node; + + node = of_get_child_by_name(np, "port"); + if (node) + return node; + + return NULL; +} +EXPORT_SYMBOL(of_graph_get_top_port); + +/** * 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 diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index d9868c2..b87a89f 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -51,6 +51,7 @@ bool of_graph_port_type_is(struct device_node *port, char *type); bool of_graph_endpoint_type_is(struct device_node *ep, char *type); int of_graph_get_endpoint_count(const struct device_node *np, char *type); struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id); +struct device_node *of_graph_get_top_port(struct device *dev); struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, struct device_node *previous); struct device_node *of_graph_get_endpoint_by_regs( -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html