From patchwork Sat Feb 4 03:36:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 93340 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp873873qgi; Fri, 3 Feb 2017 19:37:42 -0800 (PST) X-Received: by 10.84.198.164 with SMTP id p33mr554749pld.85.1486179462714; Fri, 03 Feb 2017 19:37:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si22487114pgc.59.2017.02.03.19.37.41; Fri, 03 Feb 2017 19:37:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753744AbdBDDhk (ORCPT + 25 others); Fri, 3 Feb 2017 22:37:40 -0500 Received: from mail-ot0-f196.google.com ([74.125.82.196]:33154 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753520AbdBDDgl (ORCPT ); Fri, 3 Feb 2017 22:36:41 -0500 Received: by mail-ot0-f196.google.com with SMTP id f9so4402114otd.0; Fri, 03 Feb 2017 19:36:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U6UWQfZI/pja9PbrMhNLHhBdpMuK/r79vrh+C/unM8I=; b=jXBDDucgKz9N/wxpB/P/JOMik/boux+C3sNJ8doTizQ6m18tt/twkNh8Wskwf8oVYl CydSpxaKRYg2K3LQTRTWNDxR+4PdbnbttjG3vZMXKmsDv624gEBr2LOJuhaJoNsP0D/d fDtsxkzyY0wILuZGffMG9s70VEzwBzIV3DKDLQ77zICZV/DKs47gt5X4Ot9f0xf/WdWQ 40YVDWeOlzM1kIkJ+pLrcEDFvdHYkaGwvXuXt7sIL2tBowSj3jPAZgA2iutxcJBWfcC3 yybChBSqJeinb72miy7ZNTEuoab6J04sahELoqUYHwJpWmSTklasORh1s0LTNJEpLfno AUhA== X-Gm-Message-State: AMke39lHb8GrhzcCurn7Pzj1OQ29RQiGIzAAlso8MGe19UVMvvZE4FiG9/7WsN0ve1wgog== X-Received: by 10.157.13.33 with SMTP id 30mr20713oti.89.1486179400406; Fri, 03 Feb 2017 19:36:40 -0800 (PST) Received: from rob-hp-laptop.herring.priv (66-90-148-125.dyn.grandenetworks.net. [66.90.148.125]) by smtp.googlemail.com with ESMTPSA id j61sm15170347otc.22.2017.02.03.19.36.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 19:36:39 -0800 (PST) From: Rob Herring To: David Airlie , Daniel Vetter , Sean Paul Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.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 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 Subject: [PATCH 1/5] of: introduce of_graph_get_remote_node Date: Fri, 3 Feb 2017 21:36:31 -0600 Message-Id: <20170204033635.10250-2-robh@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170204033635.10250-1-robh@kernel.org> References: <20170204033635.10250-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.10.1 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) +{ + 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); + 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); diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index bb3a5a2cd570..7b71d3e09209 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -51,6 +51,8 @@ struct device_node *of_graph_get_endpoint_by_regs( struct device_node *of_graph_get_remote_port_parent( const struct device_node *node); struct device_node *of_graph_get_remote_port(const struct device_node *node); +struct device_node *of_graph_get_remote_node(const struct device_node *node, + int port, int endpoint); #else static inline int of_graph_parse_endpoint(const struct device_node *node, @@ -89,6 +91,12 @@ static inline struct device_node *of_graph_get_remote_port( { return NULL; } +static inline struct device_node *of_graph_get_remote_node( + const struct device_node *node, + int port, int endpoint) +{ + return NULL; +} #endif /* CONFIG_OF */