From patchwork Wed Jun 29 00:36:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9204155 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 16B9B60752 for ; Wed, 29 Jun 2016 00:40:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 063A328552 for ; Wed, 29 Jun 2016 00:40:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE6AB2862D; Wed, 29 Jun 2016 00:40:18 +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=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D634D28552 for ; Wed, 29 Jun 2016 00:40:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D712A265A2E; Wed, 29 Jun 2016 02:40:16 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D7A63265D8B; Wed, 29 Jun 2016 02:38:24 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8D25326669E; Wed, 29 Jun 2016 02:38:23 +0200 (CEST) Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com [210.160.252.173]) by alsa0.perex.cz (Postfix) with ESMTP id E31982654ED for ; Wed, 29 Jun 2016 02:36:55 +0200 (CEST) Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie2.idc.renesas.com with ESMTP; 29 Jun 2016 09:36:54 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 738013D643; Wed, 29 Jun 2016 09:36:54 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 6329F8002E; Wed, 29 Jun 2016 09:36:54 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 5BA128002D; Wed, 29 Jun 2016 09:36:54 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac1.idc.renesas.com with ESMTP id KAP05134; Wed, 29 Jun 2016 09:36:54 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="213979311" Received: from mail-pu1apc01lp0019.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.19]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 29 Jun 2016 09:36:53 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=2oZ6B+vmkFT05xMOfiK9jiAy7jGpG/wY37+3aOspnTw=; b=l1TDkCeAZk+GYYjJLH6RIcCNTq4Edor60g3g85vOV68bWk9LFpV0qMzhFOJxlvBzNNNybfb6jt4Js1sXcXKgsyw09ETkYgdR9Rx1l+itFDuLNccCSlW+1g9zfHgrUSiuc+hE4QCrV0diiSC5nvgHaYvEXVm3p13QbJwoK2llOTM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by HK2PR06MB1697.apcprd06.prod.outlook.com (10.167.73.11) with Microsoft SMTP Server (TLS) id 15.1.523.12; Wed, 29 Jun 2016 00:36:50 +0000 Message-ID: <87bn2kg7lr.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") To: Rob Herring , Mark Brown , Mark Brown , Laurent , Guennadi , Grant Likely , Frank Rowand In-Reply-To: <87k2h8g7rr.wl%kuninori.morimoto.gx@renesas.com> References: <87k2h8g7rr.wl%kuninori.morimoto.gx@renesas.com> Date: Wed, 29 Jun 2016 00:36:50 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR06CA0033.apcprd06.prod.outlook.com (10.164.91.43) To HK2PR06MB1697.apcprd06.prod.outlook.com (10.167.73.11) X-MS-Office365-Filtering-Correlation-Id: 63ff8d15-0cc0-4a49-211b-08d39fb5767b X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1697; 2:Tbji6FqTPHxqySZ9fj8XiBtpwazwYrkdM06ZNkEj7hEsVlaCjGmDdxz4r89Lxulo7YGRnQF4r984vAIL/7QwphTkqD/pARRhGwQT/S6WHMD2kP8SsaThNNieNVZFXhgdZddCr9YavwspHVSIOOjEXmcGvMoujj03Jpsv5eZc8e0BwiFne1JeKeH8xaIi46y9; 3:I+tvQsKYXtC5gS7NbmGcO+lTNBh1U+QG5gzRWh8v7FsqVm1/y7D0LAeC4zr4J88tgAJKQKcCLc2MIY9vU+9W8lbrcDpgfG0YuCqxQfgwSTwadRZ4vfyCxrsvw2YuEOQe; 25:3BPbXkLIQ8DCE/7/XAvY8aRZyP3Rbwb7imfHGEuOzqq1K9BVoHsTzkYffBRP/ByCyJcohER7hK28N29y6JQS722genBX3+W4KXkWa8KuAP/cijBcmsUtThc993qtikeVcjD0ko9e2ryFSNtPHuFX373h3CgY1mc4ZNee4iPT0/eT17kv4IvTOd5xV8e4Q4ITUnG7CL1WTKayfahWv59Lu5l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N54xkm0YluL4W/B3LnKVxhi5O+yR7I74DA+zWLG3jhu3000JlyNNSG8IRYIItxsdBze6RnIuZifJJ2dL6H9Ms7SSRzslYFmRdK3EyoNcbVaxXrnwe7S54XmHwFcfrAlTEnBveBykyKGBxgMrHKmFMQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:HK2PR06MB1697; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1697; X-Forefront-PRVS: 09888BC01D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(229853001)(19580395003)(19580405001)(77096005)(47776003)(83506001)(105586002)(69596002)(86362001)(8676002)(66066001)(46406003)(106356001)(8666005)(101416001)(81166006)(81156014)(68736007)(2950100001)(42186005)(6116002)(92566002)(3846002)(23726003)(33646002)(53416004)(7736002)(4326007)(36756003)(189998001)(50466002)(50986999)(7846002)(586003)(97736004)(2906002)(4001350100001)(76176999)(54356999)(5001770100001)(305945005)(7059030)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1697; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1697; 23:MTTtIZnbM6g+vM0kqfkSh0jTa3oNEoLMpQS0FX7yN?= =?us-ascii?Q?s3S+NjER/mkeddy5LS8qfeMHT2ANPUKWGg/JcO1/+tou9W3v+I4EYkp81Mx6?= =?us-ascii?Q?oc88jcTpbbBqa0xcMjReUg+8/le/GjUezAv9XEdEmkBbpBUaW238nbvgTQgU?= =?us-ascii?Q?ddQorq+x2zAAFh/4EQyLmHM4quJ8hiMWbCSF7t2Quhh0NzmqJ3QEYZCTHqZS?= =?us-ascii?Q?3ukHjptU3B7YPdc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av1EOc1lpag== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1697; 20:oP2YggviKUsbBOJm6mM3r/7Il2KoUCTgviyoZ2UXE9FDO+CEVJGLU/EQSUwJ8K2sM7N5UfOWogzHRrr+PO1+7w6lKhda0InU68odjRXjS5bvsD3OoaVrVdZktjoktUZIYRuhR6X2B/+weZa4CTVa564l7SNePd+Fd4g9Oz6LrhA= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2016 00:36:50.6773 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1697 Cc: Linux-DT , Linux-ALSA , Linux-Kernel Subject: [alsa-devel] [PATCH v2 6/7] of_graph: add for_each_of_port() / for_each_of_endpoint_in_port() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto OF graph indicates each devices connection. It already has for_each_endpoint_of_node() which is for-loop for each endpoint. But, some driver needs for-loop for each port[s], and for-loop for each endpoint in port[s]. This patch adds for_each_of_port() and for_each_of_endpoint_in_port() for this purpose. And it also adds for_each_of_endpoint() which is similar to for_each_endpoint_of_node(). The difference is it can catch port handle during for-loop. Signed-off-by: Kuninori Morimoto --- drivers/of/base.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_graph.h | 28 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index a085961..a39d483 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2249,6 +2249,68 @@ struct device_node *of_graph_get_top_port(struct device *dev) EXPORT_SYMBOL(of_graph_get_top_port); /** + * of_graph_get_next_port() - get next port node + * @parent: pointer to the parent device node + * @prev: previous endpoint node, or NULL to get first + * + * Return: An 'endpoint' node pointer with refcount incremented. Refcount + * of the passed @prev node is decremented. + */ +struct device_node *of_graph_get_next_port(const struct device_node *parent, + struct device_node *prev) +{ + struct device_node *port; + struct device_node *node; + + if (!parent) + return NULL; + + node = of_get_child_by_name(parent, "ports"); + if (node) + parent = node; + + /* + * Start by locating the port node. If no previous endpoint is specified + * search for the first port node, otherwise get the previous endpoint + * parent port node. + */ + if (!prev) { + port = of_get_child_by_name(parent, "port"); + if (!port) + pr_err("%s(): no port node found in %s\n", + __func__, parent->full_name); + } else { + do { + port = of_get_next_child(parent, prev); + if (!port) + break; + } while (of_node_cmp(port->name, "port")); + } + + of_node_put(node); + + return port; +} +EXPORT_SYMBOL(of_graph_get_next_port); + +/** + * of_graph_get_next_endpoint_in_port() - get next endpoint node in port + * @parent: pointer to the parent device node + * @prev: previous endpoint node, or NULL to get first + * + * Return: An 'endpoint' node pointer with refcount incremented. Refcount + * of the passed @prev node is decremented. + */ +struct device_node *of_graph_get_next_endpoint_in_port(const struct device_node *port, + struct device_node *prev) +{ + if (!port) + return NULL; + + return of_get_next_child(port, prev); +} + +/** * of_graph_get_next_endpoint() - get next endpoint node * @parent: pointer to the parent device node * @prev: previous endpoint node, or NULL to get first diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index 35e9a6e..c88b676 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -30,6 +30,16 @@ struct of_endpoint { const struct device_node *local_node; }; +#define for_each_of_port(parent, port) \ + for (port = of_graph_get_next_port(parent, NULL); port != NULL; \ + port = of_graph_get_next_port(parent, port)) +#define for_each_of_endpoint_in_port(port, ep) \ + for (ep = of_graph_get_next_endpoint_in_port(port, NULL); ep != NULL; \ + ep = of_graph_get_next_endpoint_in_port(port, ep)) +#define for_each_of_endpoint(parent, port, ep) \ + for_each_of_port(parent, port) \ + for_each_of_endpoint_in_port(port, ep) + /** * for_each_endpoint_of_node - iterate over every endpoint in a device node * @parent: parent device node containing ports and endpoints @@ -49,6 +59,10 @@ int of_graph_parse_endpoint(const struct device_node *node, bool of_graph_port_type_is(struct device_node *port, char *type); struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id); struct device_node *of_graph_get_top_port(struct device *dev); +struct device_node *of_graph_get_next_port(const struct device_node *parent, + struct device_node *prev); +struct device_node *of_graph_get_next_endpoint_in_port(const struct device_node *port, + struct device_node *prev); 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( @@ -78,6 +92,20 @@ static inline struct device_node *of_graph_get_port_by_id( return NULL; } +static inline struct device_node *of_graph_get_next_port( + const struct device_node *parent, + struct device_node *prev) +{ + return NULL; +} + +static inline struct device_node *of_graph_get_next_endpoint_in_port( + const struct device_node *port, + struct device_node *prev) +{ + return NULL; +} + static inline struct device_node *of_graph_get_next_endpoint( const struct device_node *parent, struct device_node *previous)