From patchwork Thu Mar 26 11:15:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyungwon Hwang X-Patchwork-Id: 6097541 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 E25CFBF90F for ; Thu, 26 Mar 2015 11:15:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE878203F7 for ; Thu, 26 Mar 2015 11:15:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9C2EE20218 for ; Thu, 26 Mar 2015 11:15:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A17886E9D4; Thu, 26 Mar 2015 04:15:56 -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 412986E4C2 for ; Thu, 26 Mar 2015 04:15:52 -0700 (PDT) Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NLT0078RGMFOYC0@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 26 Mar 2015 20:15:51 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.115]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 42.FF.18167.66AE3155; Thu, 26 Mar 2015 20:15:50 +0900 (KST) X-AuditID: cbfee690-f79ab6d0000046f7-28-5513ea664d24 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 9B.B8.20081.66AE3155; Thu, 26 Mar 2015 20:15:50 +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 <0NLT00A2SGMAMQ10@mmp2.samsung.com>; Thu, 26 Mar 2015 20:15:50 +0900 (KST) From: Hyungwon Hwang To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, inki.dae@samsung.com, daniel@fooishbar.org Subject: [PATCH v3 2/8] of: add helper for getting endpoint node of specific identifiers Date: Thu, 26 Mar 2015 20:15:34 +0900 Message-id: <1427368540-28010-3-git-send-email-human.hwang@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1427368540-28010-1-git-send-email-human.hwang@samsung.com> References: <1427368540-28010-1-git-send-email-human.hwang@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkWDftlXCowZ+P1hbXvzxntbjSOp3V Yv6Rc6wW18/bWVz5+p7NYumMPlaLSfcnsFi8uHeRxWLG5JdsDpweL75uY/a4332cyaNvyypG j8+b5AJYorhsUlJzMstSi/TtErgy7r89zFrwUKKiYck29gbGFSJdjJwcEgImEv8+7mGEsMUk LtxbzwZiCwksZZR48D4NpubJ9Sb2LkYuoPh0RollW54wQTg/GCV63/0D62AT0JNYcO0HO4gt IpAr0f/iBVgRs0APo0TjlcksIAlhgSiJFY83gK1jEVCV2Ph7AyuIzSvgLtHTtJ0NYp2cxMlj k8HinAIeEj1zHjNBnOQucbZ7FzPIUAmBeewSu7/NYoMYJCDxbfIhoAUcQAlZiU0HmCHmSEoc XHGDZQKj8AJGhlWMoqkFyQXFSelFJnrFibnFpXnpesn5uZsYgQF/+t+zCTsY7x2wPsQowMGo xMP7o184VIg1say4MvcQoynQhonMUqLJ+cC4yiuJNzQ2M7IwNTE1NjK3NFMS530t9TNYSCA9 s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o8WV7/oLpCmPlblRJLcUaioRZzUXEiAEvn2AC+ AgAA 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 drivers/of/base.c | 33 +++++++++++++++++++++++++++++++++ include/linux/of_graph.h | 8 ++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index adb8764..ffc2235 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2165,6 +2165,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) {