From patchwork Fri Jun 24 02:33:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9196441 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 B3D1660871 for ; Fri, 24 Jun 2016 02:35:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A68B428485 for ; Fri, 24 Jun 2016 02:35:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ACE328487; Fri, 24 Jun 2016 02:35:07 +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 E8A4F28485 for ; Fri, 24 Jun 2016 02:35:05 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id CF08E266033; Fri, 24 Jun 2016 04:35:04 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 929AF26606C; Fri, 24 Jun 2016 04:34:05 +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 9F52E26606C; Fri, 24 Jun 2016 04:34:04 +0200 (CEST) Received: from relmlie4.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa0.perex.cz (Postfix) with ESMTP id 77FFB265AFC for ; Fri, 24 Jun 2016 04:33:26 +0200 (CEST) Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie4.idc.renesas.com with ESMTP; 24 Jun 2016 11:33:25 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 318644C02C; Fri, 24 Jun 2016 11:33:25 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 200101806F; Fri, 24 Jun 2016 11:33:25 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 1A9B31800A; Fri, 24 Jun 2016 11:33:25 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id MAR11431; Fri, 24 Jun 2016 11:33:24 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="213669752" Received: from mail-hk2apc01lp0215.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.215]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 24 Jun 2016 11:33:23 +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=dGToJhq1OTcSW7xvxYf6nMZpZicbMRvK/yEIIIHlN48=; b=FHnCq4R+Njyb68JGDZHYSEJmSugege11YPouXGCRZK8OxAixz8PqpjhTDK0a/jQNn8wXY22h2tMLD0rhFUwaOGVqam25xF//tETZbc1u2D7lP85mvULrXHxW5k2zaTr8d8HZzSjQlTQN3hO7599eu00FSZKQIDrXug5kZrAZAT4= 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 KL1PR06MB1701.apcprd06.prod.outlook.com (10.167.63.15) with Microsoft SMTP Server (TLS) id 15.1.523.12; Fri, 24 Jun 2016 02:33:20 +0000 Message-ID: <87a8ibxqy6.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Rob Herring , Mark Brown , Mark Brown , Laurent , Guennadi , Grant Likely , Frank Rowand In-Reply-To: <87fus3xr2q.wl%kuninori.morimoto.gx@renesas.com> References: <87fus3xr2q.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 24 Jun 2016 02:33:20 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0023.jpnprd01.prod.outlook.com (10.161.131.161) To KL1PR06MB1701.apcprd06.prod.outlook.com (10.167.63.15) X-MS-Office365-Filtering-Correlation-Id: b36a5a5b-f1eb-4ec6-fef0-08d39bd7e895 X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1701; 2:0q4F3MQngfma23h+9k9CkZbu3j18Ui/4TG1+JpHbt+CtcomlSIkTmBl2LOhWHWqKSF0Xc5rx1WtlmUqjmiBeLbLdYYLaai/mj/fATSV/Y/YsotMV6CW1MProkaGUvTZE6uJL3xRuHewnEwH+J7KJYS7kP2hQf77zfJdgrBNjmZjwdk0LuDgIllb2ucyr+rhg; 3:hv+on+mKp6Cux6BD5yKX/jdPgTFOcCBW84LcZE5uXuzvW+r53KCuFZqJ4yzZSME1kKvaQybI2E8pNhvMp2evqipmOKJN2bKG0rO39qjIbV4FgOlICJgOccSr3UsugizV; 25:Uag/RvMVQgjl0pO1erj/GhNu1ohJjnNDqv6x+B3XAd7woqp0ndO+q35kWet1ReCDsV8Rgy8NGwr7JsnABTBfeikHsPFFL/zyHhBvLiNYW3yqlqVC9tYnXRRV42C007Hd05Tee8BuSlkxry2mzYk9ZnC8bSjOCnLqdfjYlcy0gJFSxLZUe+8xjWFrod6PqshXARvaDWiHXz5UNu8dW19DNqakzWOwB9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a7o3LtCY4bj8ccy3iBodnEqJdItwyt+3RouV/x9naB8CYLykgLbjO6fObIVbc7MkL/G6OVCilxAFckZFDR6rmSwV1E73mQhCEJyw3stGn2QHvqHPGNXkIcGVx4RSLQpuH3vXCrgR0g== 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)(10201501046)(3002001)(6055026); SRVR:KL1PR06MB1701; BCL:0; PCL:0; RULEID:; SRVR:KL1PR06MB1701; X-Forefront-PRVS: 0983EAD6B2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(92566002)(68736007)(105586002)(6116002)(66066001)(586003)(101416001)(46406003)(4326007)(97736004)(189998001)(106356001)(229853001)(7736002)(7846002)(305945005)(3846002)(47776003)(50466002)(23726003)(83506001)(575784001)(86362001)(42186005)(2950100001)(4001350100001)(8666005)(53416004)(33646002)(77096005)(8676002)(69596002)(81156014)(5001770100001)(81166006)(2906002)(19580405001)(36756003)(19580395003)(54356999)(50986999)(76176999)(7059030)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1PR06MB1701; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; KL1PR06MB1701; 23:LI6AUmpNkbhRT+KL8Ii2dwDcebYVbD+NgKjC9z6ka?= =?us-ascii?Q?IJsXDXkTe7C/HurJ7/ClP7W4wIEMXSpl9felpDkIPuGTgZCp1kKdMFvSiNFS?= =?us-ascii?Q?5wLYUPDQFPqavZkK/QPdOLOqc3vNwHFsCPXDfQvIrLeNnVPnr1rq57oejbnf?= =?us-ascii?Q?oXgvAyGPzBWMvi5sC50jyw8qjT3wbqB4wzSF+NhsE0BKE/NY1SK8ARHwjBUN?= =?us-ascii?Q?NHJaiGTYSXxPSQrd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zypPBB8aCBwq7IUD/EQT+ufXNDM009b4fCw== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1701; 20:2mcr5T5ILdTZcJEQihAKdpTJwgEcBNxPqZWG0UAk27CSG6NBO/WIFdUFT5tfFMKf6iChNZRE5MwviNyGpK2BKEenowQiPuvSKkmLD/hdvV+ByezTgez3moCpo6JsA99EcnH6ae65wXCc4e0IbyNV0LDDuKy2L33N+Ofx5Il4rbo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2016 02:33:20.1220 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB1701 Cc: Linux-DT , Linux-ALSA , Linux-Kernel Subject: [alsa-devel] [PATCH 4/7] of_graph: add of_graph_get_endpoint_count() 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 want to count its endpoint number, same as of_get_child_count(). This patch adds of_graph_get_endpoint_count() which can check specific type. It will count all endpoint if type was NULL. Signed-off-by: Kuninori Morimoto --- drivers/of/base.c | 16 ++++++++++++++++ include/linux/of_graph.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index a0fc63c..a39d470 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2430,3 +2430,19 @@ bool of_graph_endpoint_type_is(struct device_node *ep, char *type) return of_graph_port_type_is(of_get_parent(ep), type); } EXPORT_SYMBOL(of_graph_endpoint_type_is); + +int of_graph_get_endpoint_count(const struct device_node *np, char *type) +{ + struct device_node *child; + int num = 0; + + for_each_endpoint_of_node(np, child) { + if (!type) + num++; + else + num += of_graph_endpoint_type_is(child, type); + } + + return num; +} +EXPORT_SYMBOL(of_graph_get_endpoint_count); diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index 1750d5c..86baae5 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -42,12 +42,14 @@ struct of_endpoint { #define of_graph_port_type_is_sound(n) of_graph_port_type_is(n, "sound") #define of_graph_endpoint_type_is_sound(n) of_graph_endpoint_type_is(n, "sound") +#define of_graph_get_sound_endpoint_count(n) of_graph_get_endpoint_count(n, "sound") #ifdef CONFIG_OF int of_graph_parse_endpoint(const struct device_node *node, struct of_endpoint *endpoint); bool of_graph_port_type_is(struct device_node *port, char *type); bool of_graph_endpoint_type_is(struct device_node *ep, char *type); +int of_graph_get_endpoint_count(const struct device_node *np, char *type); 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); @@ -76,6 +78,12 @@ static bool of_graph_endpoint_type_is(struct device_node *ep, char *type) return false; } +static inline int of_graph_get_endpoint_count(const struct device_node *np, + char *type) +{ + return 0; +} + static inline struct device_node *of_graph_get_port_by_id( struct device_node *node, u32 id) {