From patchwork Fri Jun 12 12:59:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyungwon Hwang X-Patchwork-Id: 6598341 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BB950C0020 for ; Fri, 12 Jun 2015 12:59:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9A8520686 for ; Fri, 12 Jun 2015 12:59:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BF50420676 for ; Fri, 12 Jun 2015 12:59:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8D7B6EAAC; Fri, 12 Jun 2015 05:59:31 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id 46CAF6EAA7 for ; Fri, 12 Jun 2015 05:59:29 -0700 (PDT) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NPU00CM81F4NK20@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 12 Jun 2015 21:59:28 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.115]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 90.9A.28411.0B7DA755; Fri, 12 Jun 2015 21:59:28 +0900 (KST) X-AuditID: cbfee68e-f79c56d000006efb-e6-557ad7b03eac Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B4.15.05312.FA7DA755; Fri, 12 Jun 2015 21:59:27 +0900 (KST) Received: from localhost.localdomain ([10.252.82.145]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NPU002KS1F1AP00@mmp2.samsung.com>; Fri, 12 Jun 2015 21:59:27 +0900 (KST) From: Hyungwon Hwang To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Subject: [PATCH v6 06/15] of: add helper for getting endpoint node of specific identifiers Date: Fri, 12 Jun 2015 21:59:01 +0900 Message-id: <1434113958-15877-7-git-send-email-human.hwang@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1434113958-15877-1-git-send-email-human.hwang@samsung.com> References: <1434113958-15877-1-git-send-email-human.hwang@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRmVeSWpSXmKPExsWyRsSkWHfD9apQg+YDzBZXWqezWsw/co7V 4srX92wWS2f0sVpMuj+BxeLFvYssFjMmv2RzYPd48XUbs8f97uNMHn1bVjF6fN4kF8ASxWWT kpqTWZZapG+XwJVxYP021oKNkhUn/71iaWBsFO1i5OSQEDCRWPnkLwuELSZx4d56ti5GLg4h gaWMEtsPXWSFKfqz4D07RGI6o8Tq/UsZIZwfjBKLvu9jAqliE9CTWHDtBzuILSJgL7H46ylW kCJmgW5GiZXnn4IlhAViJFad3MoGYrMIqErcezcNLM4r4C6xqnUeM8Q6OYmTxyaDreYU8JC4 e/AW2H1CQDX/7x8CO0NCYDK7xIX5U6EGCUh8m3wIqIgDKCErsekA1BxJiYMrbrBMYBRewMiw ilE0tSC5oDgpvchIrzgxt7g0L10vOT93EyMwwE//e9a3g/HmAetDjAIcjEo8vAlaVaFCrIll xZW5hxhNgTZMZJYSTc4HxlFeSbyhsZmRhamJqbGRuaWZkjhvgtTPYCGB9MSS1OzU1ILUovii 0pzU4kOMTBycUg2ME5OfnF577WuF7KFX55+rb3hzdofcf8eqA/qxiZmenetWmgj8qrMs9Enr WqcTJCU3+0mXhPakA1XuBYump3w8vun4t4+bCm912pRO2hvwTaJEZ71A5IdiKwP+jOm7ghjO mN0yd0wOCsplW8vo39d5VifkZIRGIHemxRW5H+aPPxs5bNTiTgtTYinOSDTUYi4qTgQAMshc /msCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEIsWRmVeSWpSXmKPExsVy+t9jQd3116tCDWbNsLa40jqd1WL+kXOs Fle+vmezWDqjj9Vi0v0JLBYv7l1ksZgx+SWbA7vHi6/bmD3udx9n8ujbsorR4/MmuQCWqAZG m4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE3FRbJRefAF23zBygE5QUyhJz SoFCAYnFxUr6dpgmhIa46VrANEbo+oYEwfUYGaCBhDWMGQfWb2Mt2ChZcfLfK5YGxkbRLkZO DgkBE4k/C96zQ9hiEhfurWfrYuTiEBKYziixev9SRgjnB6PEou/7mECq2AT0JBZc+wHWISJg L7H46ylWkCJmgW5GiZXnn4IlhAViJFad3MoGYrMIqErcezcNLM4r4C6xqnUeM8Q6OYmTxyaz gticAh4Sdw/eYgGxhYBq/t8/xD6BkXcBI8MqRtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjOD4 eSa9g3FVg8UhRgEORiUe3gStqlAh1sSy4srcQ4wSHMxKIrzd24FCvCmJlVWpRfnxRaU5qcWH GE2BrprILCWanA+M7bySeENjEzMjSyNzQwsjY3Mlcd6T+T6hQgLpiSWp2ampBalFMH1MHJxS DYzyyoWps3eZizyVY5m948X+g63LpSNEdr5/45bJmidTf/xv//7864vaFXpyrtpZxkYkLhOL m+ZkcYc5S+X1emllK4az71cb/rIUn/1Z0fComdd6hoiD9rY6gh+2zTmvmJFT+vfTuweOSQZl HcXtLNejZCY8vhfNrbHFOa3t0BPxuJdRkVNXHlViKc5INNRiLipOBACAoJnTtQIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: sw0312.kim@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 before: - Refer https://patchwork.kernel.org/patch/6191751/ Changes for v6: - 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 99764db..f3b583b 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2233,6 +2233,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 7bc92e0..1c1d5b9 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -45,6 +45,8 @@ int of_graph_parse_endpoint(const struct device_node *node, struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id); 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); @@ -69,6 +71,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) {