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 (Arm)" X-Patchwork-Id: 9556999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1BEA06021C for ; Mon, 6 Feb 2017 01:25:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F90520242 for ; Mon, 6 Feb 2017 01:25:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03C9626C9B; Mon, 6 Feb 2017 01:25:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7E3720242 for ; Mon, 6 Feb 2017 01:25:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24A376E2A2; Mon, 6 Feb 2017 01:24:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot0-f195.google.com (mail-ot0-f195.google.com [74.125.82.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1AC9E6E14F for ; Sat, 4 Feb 2017 03:36:41 +0000 (UTC) Received: by mail-ot0-f195.google.com with SMTP id 36so4380605otx.3 for ; Fri, 03 Feb 2017 19:36:41 -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=bS+D56wu7H6JemBU1A2XQcq1rxdd5JlWPSQeb4RSyoEpkd8Nb4nqYCXHY9Y6cDCgzy k4HrfByY8C+xzQHwRtDjaifJGJQkywo2tVQcQg+9Azte7pQW7Ksk7goEJtkuYyj/yF5k SmyJARoy92Lf3kfDLPpjo3HROMWEtVgq60Chsso/bvIMF5msxAULTUUAwzRhNHjgwDRf hbLJDpdp5dF4assoFQ5ci1YSXb65yQ5j/yLIyICptHZxxf36m8/+kzCxBFmcUVY+cAWu z44vXaULd7dANpqopCwQ6Vtu2AAVWChBgBemNBTioa1rAfxjAdGgREvlf1nkh0Q24Kja 4U6A== X-Gm-Message-State: AMke39luwOd+V8v2SKnt72zou91ospJiSmP9cY+89EqNovS1RHXCgn/B6GNUW18RUb59Zw== 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 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> X-Mailman-Approved-At: Mon, 06 Feb 2017 01:24:20 +0000 Cc: Neil Armstrong , Liviu Dudau , dri-devel@lists.freedesktop.org, Tomi Valkeinen , Frank Rowand , Marek Vasut , Kevin Hilman , Chen-Yu Tsai , Krzysztof Kozlowski , Xinliang Liu , Javier Martinez Canillas , Xinwei Kong , Kukjin Kim , Mali DP Maintainers , devicetree@vger.kernel.org, Chen Feng , Jyri Sarha , Carlo Caione , Russell King , Matthias Brugger , Alison Wang , Jingoo Han , Seung-Woo Kim , linux-kernel@vger.kernel.org, Kyungmin Park , Rongrong Zou , Maxime Ripard X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Philipp Zabel --- 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) +{ + 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 */