From patchwork Thu Mar 12 14:29:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyungwon Hwang X-Patchwork-Id: 5995421 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 A5D72BF911 for ; Thu, 12 Mar 2015 14:30:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C54FB20437 for ; Thu, 12 Mar 2015 14:30:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C480520431 for ; Thu, 12 Mar 2015 14:30:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D412E6E9BF; Thu, 12 Mar 2015 07:30:08 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 562176E437 for ; Thu, 12 Mar 2015 07:30:05 -0700 (PDT) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NL3003MTSA4VX40@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 12 Mar 2015 23:30:04 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.114]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id CE.25.18484.CE2A1055; Thu, 12 Mar 2015 23:30:04 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-b6-5501a2ecc6be Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AC.DE.20081.CE2A1055; Thu, 12 Mar 2015 23:30:04 +0900 (KST) Received: from localhost.localdomain ([10.252.82.145]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NL300BLZSA0IP20@mmp2.samsung.com>; Thu, 12 Mar 2015 23:30:04 +0900 (KST) From: Hyungwon Hwang To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Subject: [PATCH 2/6] of: add helper for getting endpoint node of specific identifiers Date: Thu, 12 Mar 2015 23:29:53 +0900 Message-id: <1426170597-9606-3-git-send-email-human.hwang@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1426170597-9606-1-git-send-email-human.hwang@samsung.com> References: <1426170597-9606-1-git-send-email-human.hwang@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsWyRsSkSPfNIsZQg6cnxS3mHznHanHl63s2 i6Uz+lgtJt2fwGLx4t5FFosZk1+yObB53O8+zuTRt2UVo8fnTXIBzFFcNimpOZllqUX6dglc Gb/3zmItWClRsXAOZwNji0gXIyeHhICJxPy9y5ghbDGJC/fWs3UxcnEICSxllLj5ZwsrTNG+ 97OgEtMZJXZtnArltDFJTJl7ngWkik1AT2LBtR/sILaIgL3E4q+nwLqZBUol7sxfDLZCWCBc YvaLVWA1LAKqEn+PXWPsYuTg4BVwk2j/bAOxTE7i5LHJYK2cAu4Sp3fvZAOxhYBKDjyezA6y V0LgP5vE5WmT2CDmCEh8m3yIBWSOhICsxKYDUN9IShxccYNlAqPwAkaGVYyiqQXJBcVJ6UXG esWJucWleel6yfm5mxiBYXz637P+HYx3D1gfYhTgYFTi4b3wnSFUiDWxrLgy9xCjKdCGicxS osn5wGjJK4k3NDYzsjA1MTU2Mrc0UxLnXSj1M1hIID2xJDU7NbUgtSi+qDQntfgQIxMHp1QD o9vvaIlAiVc7X1dHuPfciShQWfRIZOHKE+X1y1/bxtbtv3iXL4TDb0LM/58v353XmBcwcXtH 0aHjM2c1CDce1Pm1Tuz083sTizmzghS5Ft41OcV5xSk6qye5/KPnHPUX7POmeYW31ya0S6rt FZ113j45jkPS0OPuwtW3ZoSetGp+afZHj79wnhJLcUaioRZzUXEiADh6MaBeAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRmVeSWpSXmKPExsVy+t9jQd03ixhDDY484reYf+Qcq8WVr+/Z LJbO6GO1mHR/AovFi3sXWSxmTH7J5sDmcb/7OJNH35ZVjB6fN8kFMEc1MNpkpCampBYppOYl 56dk5qXbKnkHxzvHm5oZGOoaWlqYKynkJeam2iq5+AToumXmAC1WUihLzCkFCgUkFhcr6dth mhAa4qZrAdMYoesbEgTXY2SABhLWMGb83juLtWClRMXCOZwNjC0iXYycHBICJhL73s9ig7DF JC7cWw9kc3EICUxnlNi1cSqU08YkMWXueRaQKjYBPYkF136wg9giAvYSi7+eYgWxmQVKJe7M X8wMYgsLhEvMfrEKrIZFQFXi77FrjF2MHBy8Am4S7Z9tIJbJSZw8NhmslVPAXeL07p1gRwgB lRx4PJl9AiPvAkaGVYyiqQXJBcVJ6bmGesWJucWleel6yfm5mxjBUfJMagfjygaLQ4wCHIxK PLwVXxlChVgTy4orcw8xSnAwK4nwms5nDBXiTUmsrEotyo8vKs1JLT7EaAp01ERmKdHkfGAE 55XEGxqbmBlZGpkbWhgZmyuJ8yrZt4UICaQnlqRmp6YWpBbB9DFxcEo1MKb8NRE5osbNoLbw 2uZ9+htFOMz7Ozy8Z/5+Fz6V8wNr6BnH087KliYJNgkWmyNevOeqXT6rdMLv217xpYy97Hdn TnqWmrjPQNCqdXtHsqx7/vo7bTfj07bxXuie2CZbYfRpthSLgzfjrzn1fw1CEtmmT2+/G2w5 o2zDhT+nQ3W5P099/fBCihJLcUaioRZzUXEiACEvSyuoAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: sw0312.kim@samsung.com, Hyungwon Hwang 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 --- 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 36536b6..d7fa99d 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2155,6 +2155,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) {