From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751344AbdBDQKf (ORCPT ); Sat, 4 Feb 2017 11:10:35 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:40770 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953AbdBDQKd (ORCPT ); Sat, 4 Feb 2017 11:10:33 -0500 Subject: Re: [PATCH 1/5] of: introduce of_graph_get_remote_node To: Rob Herring , David Airlie , Daniel Vetter , Sean Paul References: <20170204033635.10250-1-robh@kernel.org> <20170204033635.10250-2-robh@kernel.org> CC: , , , Frank Rowand , Boris Brezillon , Archit Taneja , Jingoo Han , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Kukjin Kim , Krzysztof Kozlowski , Javier Martinez Canillas , Stefan Agner , Alison Wang , Xinliang Liu , Rongrong Zou , Xinwei Kong , Chen Feng , Philipp Zabel , CK Hu , Matthias Brugger , Marek Vasut , Mark Yao , Heiko Stuebner , Maxime Ripard , Chen-Yu Tsai , Liviu Dudau , Mali DP Maintainers , Neil Armstrong , Carlo Caione , Kevin Hilman , Rob Clark , Jyri Sarha , Tomi Valkeinen , Eric Anholt , Russell King From: Vladimir Zapolskiy Message-ID: <6efd793f-944d-53e6-9b4b-1a78ea835cf5@mentor.com> Date: Sat, 4 Feb 2017 18:10:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: <20170204033635.10250-2-robh@kernel.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [137.202.0.87] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Rob, On 02/04/2017 05:36 AM, Rob Herring wrote: > The OF graph API leaves too much of the graph walking to clients when > in many cases the driver doesn't care about accessing the port or > endpoint nodes. The drivers typically just want the device connected via > a particular graph connection. of_graph_get_remote_node provides this > functionality. > > Signed-off-by: Rob Herring > --- > drivers/of/base.c | 28 ++++++++++++++++++++++++++++ > include/linux/of_graph.h | 8 ++++++++ > 2 files changed, 36 insertions(+) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index d4bea3c797d6..ea18ab16b92c 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -2469,3 +2469,31 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node) > return of_get_next_parent(np); > } > EXPORT_SYMBOL(of_graph_get_remote_port); > + > +struct device_node *of_graph_get_remote_node(const struct device_node *node, > + int port, int endpoint) it would be nice to add a short comment that a returned device node is expected to be dereferenced with of_node_put(). > +{ > + struct device_node *endpoint_node, *remote; > + > + endpoint_node = of_graph_get_endpoint_by_regs(node, port, endpoint); > + if (!endpoint_node) { > + pr_debug("no valid endpoint (%d, %d) for node %s\n", > + port, endpoint, node->full_name); > + return NULL; > + } > + > + remote = of_graph_get_remote_port_parent(endpoint_node); > + of_node_put(endpoint); Typo, here it should be of_node_put(endpoint_node); > + if (!remote) { > + pr_debug("no valid remote node\n"); > + return NULL; > + } > + > + if (!of_device_is_available(remote)) { > + pr_debug("not available for remote node\n"); > + return NULL; > + } > + > + return remote; > +} > +EXPORT_SYMBOL(of_graph_get_remote_node); -- With best wishes, Vladimir From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vladimir Zapolskiy Subject: Re: [PATCH 1/5] of: introduce of_graph_get_remote_node Date: Sat, 4 Feb 2017 18:10:14 +0200 Message-ID: <6efd793f-944d-53e6-9b4b-1a78ea835cf5@mentor.com> References: <20170204033635.10250-1-robh@kernel.org> <20170204033635.10250-2-robh@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170204033635.10250-2-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Rob Herring , David Airlie , Daniel Vetter , Sean Paul Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Frank Rowand , Boris Brezillon , Archit Taneja , Jingoo Han , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Kukjin Kim , Krzysztof Kozlowski , Javier Martinez Canillas , Stefan Agner , Alison Wang , Xinliang Liu , Rongrong Zou , Xinwei Kong , Chen List-Id: devicetree@vger.kernel.org Hi Rob, On 02/04/2017 05:36 AM, Rob Herring wrote: > The OF graph API leaves too much of the graph walking to clients when > in many cases the driver doesn't care about accessing the port or > endpoint nodes. The drivers typically just want the device connected via > a particular graph connection. of_graph_get_remote_node provides this > functionality. > > Signed-off-by: Rob Herring > --- > drivers/of/base.c | 28 ++++++++++++++++++++++++++++ > include/linux/of_graph.h | 8 ++++++++ > 2 files changed, 36 insertions(+) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index d4bea3c797d6..ea18ab16b92c 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -2469,3 +2469,31 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node) > return of_get_next_parent(np); > } > EXPORT_SYMBOL(of_graph_get_remote_port); > + > +struct device_node *of_graph_get_remote_node(const struct device_node *node, > + int port, int endpoint) it would be nice to add a short comment that a returned device node is expected to be dereferenced with of_node_put(). > +{ > + struct device_node *endpoint_node, *remote; > + > + endpoint_node = of_graph_get_endpoint_by_regs(node, port, endpoint); > + if (!endpoint_node) { > + pr_debug("no valid endpoint (%d, %d) for node %s\n", > + port, endpoint, node->full_name); > + return NULL; > + } > + > + remote = of_graph_get_remote_port_parent(endpoint_node); > + of_node_put(endpoint); Typo, here it should be of_node_put(endpoint_node); > + if (!remote) { > + pr_debug("no valid remote node\n"); > + return NULL; > + } > + > + if (!of_device_is_available(remote)) { > + pr_debug("not available for remote node\n"); > + return NULL; > + } > + > + return remote; > +} > +EXPORT_SYMBOL(of_graph_get_remote_node); -- With best wishes, Vladimir -- 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