From patchwork Tue Apr 7 11:57:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyungwon Hwang X-Patchwork-Id: 6169181 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C334F9F349 for ; Tue, 7 Apr 2015 11:57:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C817E2021F for ; Tue, 7 Apr 2015 11:57:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B883E202F8 for ; Tue, 7 Apr 2015 11:57:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9C426E140; Tue, 7 Apr 2015 04:57:46 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id B23636E0FA for ; Tue, 7 Apr 2015 04:57:44 -0700 (PDT) Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NMF00ATBQK8C750@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 07 Apr 2015 20:57:44 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.115]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 74.38.18889.736C3255; Tue, 7 Apr 2015 20:57:43 +0900 (KST) X-AuditID: cbfee68d-f79266d0000049c9-12-5523c6378ce2 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id C9.43.25346.636C3255; Tue, 7 Apr 2015 20:57:43 +0900 (KST) Received: from localhost.localdomain ([10.252.82.145]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NMF000O2QK4KX20@mmp1.samsung.com>; Tue, 07 Apr 2015 20:57:42 +0900 (KST) From: Hyungwon Hwang To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, inki.dae@samsung.com, daniel@fooishbar.org Subject: [PATCH v4 2/8] of: add helper for getting endpoint node of specific identifiers Date: Tue, 07 Apr 2015 20:57:32 +0900 Message-id: <1428407858-25523-3-git-send-email-human.hwang@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1428407858-25523-1-git-send-email-human.hwang@samsung.com> References: <1428407858-25523-1-git-send-email-human.hwang@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkWNf8mHKowY4lfBbXvzxntbjSOp3V Yv6Rc6wW18/bWVz5+p7NYumMPlaLSfcnsFi8uHeRxWLG5JdsDpweL75uY/a4332cyaNvyypG j8+b5AJYorhsUlJzMstSi/TtErgynu85zlrwVaLi7flLrA2Mu0S6GDk5JARMJLa9/s4IYYtJ XLi3nq2LkYtDSGApo8Sens3sMEU7p65igkgsYpSYevsalPODUeLV7qNsIFVsAnoSC679AOsQ EciV6H/xAqyIWaCHUaLxymQWkISwQJTEkpfrwIpYBFQlOla8BtvNK+Ausffdb6h1chInj01m 7WLk4OAU8JBYPT8UJCwEVLKp7RUzyEwJgUXsEp++3GaDmCMg8W3yIRaQegkBWYlNB5ghxkhK HFxxg2UCo/ACRoZVjKKpBckFxUnpRYZ6xYm5xaV56XrJ+bmbGIEBf/rfs94djLcPWB9iFOBg VOLhZZBTDhViTSwrrsw9xGgKtGEis5Rocj4wrvJK4g2NzYwsTE1MjY3MLc2UxHkVpX4GCwmk J5akZqemFqQWxReV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FGoqEWc1FxIgALZbKR vQIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: dh09.lee@samsung.com, sw0312.kim@samsung.com, Hyungwon Hwang , cw00.choi@samsung.com 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When there are multiple ports or multiple endpoints in a port, they have to be distinguished by the value of reg property. It is common. The drivers can get the specific endpoint in the specific port via this function. Now the drivers have to implement this code in themselves or have to force the order of dt nodes to get the right node. Signed-off-by: Hyungwon Hwang Acked-by: Rob Herring --- Changes for v2: - None Changes for v3: - None Changes for v4: - None drivers/of/base.c | 33 +++++++++++++++++++++++++++++++++ include/linux/of_graph.h | 8 ++++++++ 2 files changed, 41 insertions(+) -- 1.9.1 diff --git a/drivers/of/base.c b/drivers/of/base.c index 8f165b1..37bc8e0 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2158,6 +2158,39 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, EXPORT_SYMBOL(of_graph_get_next_endpoint); /** + * of_graph_get_endpoint_by_regs() - get endpoint node of specific identifiers + * @parent: pointer to the parent device node + * @port_reg: identifier (value of reg property) of the parent port node + * @reg: identifier (value of reg property) of the endpoint node + * + * Return: An 'endpoint' node pointer which is identified by reg and at the same + * is the child of a port node identified by port_reg. reg and port_reg are + * ignored when they are -1. + */ +struct device_node *of_graph_get_endpoint_by_regs( + const struct device_node *parent, int port_reg, int reg) +{ + struct of_endpoint endpoint; + struct device_node *node, *prev_node = NULL; + + while (1) { + node = of_graph_get_next_endpoint(parent, prev_node); + of_node_put(prev_node); + if (!node) + break; + + of_graph_parse_endpoint(node, &endpoint); + if (((port_reg == -1) || (endpoint.port == port_reg)) && + ((reg == -1) || (endpoint.id == reg))) + return node; + + prev_node = node; + } + + return NULL; +} + +/** * of_graph_get_remote_port_parent() - get remote port's parent node * @node: pointer to a local endpoint device_node * diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index befef42..e859eb7 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -31,6 +31,8 @@ int of_graph_parse_endpoint(const struct device_node *node, struct of_endpoint *endpoint); 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( + const struct device_node *parent, int port_reg, int reg); 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); @@ -49,6 +51,12 @@ static inline struct device_node *of_graph_get_next_endpoint( return NULL; } +struct device_node *of_graph_get_endpoint_by_regs( + const struct device_node *parent, int port_reg, int reg) +{ + return NULL; +} + static inline struct device_node *of_graph_get_remote_port_parent( const struct device_node *node) {