From patchwork Tue May 31 09:03:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9143867 X-Patchwork-Delegate: geert@linux-m68k.org 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 D6C8D60757 for ; Tue, 31 May 2016 09:03:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8E5E27BF1 for ; Tue, 31 May 2016 09:03:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA82F28185; Tue, 31 May 2016 09:03:16 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12AF227BF1 for ; Tue, 31 May 2016 09:03:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756962AbcEaJDO (ORCPT ); Tue, 31 May 2016 05:03:14 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:40992 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756900AbcEaJDL (ORCPT ); Tue, 31 May 2016 05:03:11 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 31 May 2016 18:03:04 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 193D753033; Tue, 31 May 2016 18:03:04 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id F0C0C8002D; Tue, 31 May 2016 18:03:03 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id A54938002F; Tue, 31 May 2016 18:03:03 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id UBQ01130; Tue, 31 May 2016 18:03:03 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="212431792" Received: from mail-pu1apc01lp0016.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.16]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 31 May 2016 18:03:01 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=wEC2ieL/g6IWsMTYYxS7mCWC91QtfwsfYAUp1aSCqHQ=; b=hmn8BJy94oC7+WaRex/6PJ2LYNuIzeo1KP7sRIAxiijUKqe1tCxIWoby4//LHFg3LHn1POLnMO6Fg2x0mLRgP+kfw5fjXd7IixcJK45DqeE2Y+5eFevKqQRV5IOC49Ubw7rhhochPSlk2pj9eYY9M447Vs6br3IVNB8/oEy0VU0= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by HK2PR06MB1699.apcprd06.prod.outlook.com (10.167.73.13) with Microsoft SMTP Server (TLS) id 15.1.506.9; Tue, 31 May 2016 09:03:00 +0000 Message-ID: <871t4isj0b.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 10/39 v2] ASoC: simple-card-utils: add asoc_simple_card_parse_endpoint() User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown CC: Linux-ALSA , Liam Girdwood , Simon , In-Reply-To: <87fusysjam.wl%kuninori.morimoto.gx@renesas.com> References: <87fusysjam.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Tue, 31 May 2016 09:03:00 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0017.jpnprd01.prod.outlook.com (10.161.131.155) To HK2PR06MB1699.apcprd06.prod.outlook.com (10.167.73.13) X-MS-Office365-Filtering-Correlation-Id: 02173e3b-25bb-4137-1b0d-08d389325df1 X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1699; 2:SnC+Q+7lL7F2ayvNIesrhXm0NCEo7qLk5yfH/APCyd6GkXaSxz1xjtrOsFsFAGFEPQdp/KfZ9vGmddiqJinMTlYv1HePRxDqu4GD93xh/jkrVNSX89iT8rrYA/kYoO0HKDqztP+sZdXDzKbNtVJkZtjieUmvhmpDxs7FpDOAnwF4oC6zS/fGksW8xcuYOL/c; 3:T3LmMglS24vtrdsvkqKJijgt8py22Xc4fmxWRTYZu/qbO+a2mrCdNBT2rMMu217DyGCXMNZ0jiiHyGeWBtvmzlWjzxCxtd9OLtnZ+a+lYllApZgdE+idk16H17Hl7Hp6; 25:CGoPfRYRPEridQAOI7OVPFHUTLof4RbpDArg+H0w8Ow0w/r7ZE/k0LThCbasIqZxDTObYwlYT6fXjt2L52hEK4O+gMqfJPrkY9MxzZHa/8aw24dOyrgv70kLuiC3pFwucZyb1bAymjt5tBS4sixGWYPX+1Ve8kizjlBjLj1NLnhbhv5K557aJC+g/IVP6Zdh7J8Rc5xbHnbCkjrfRZfsHQ0t2GlK0P5zT44NzKa+ASmZ0zW7HjzFMIBizYmmsfnhu7ihWHhFVDLR/Rfg+jh7xAWelkOED3GhztWoEDG44z2rTEE39mIIKAMjC7rq4jLwS0WVVKQoH6+6L2urcTfqJ8BkeRgSQDZUsTaEN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sVPMtZO8eEQ9BsXBnA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:HK2PR06MB1699; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1699; X-Forefront-PRVS: 095972DF2F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(46406003)(42186005)(19580395003)(19580405001)(189998001)(66066001)(36756003)(2906002)(50466002)(5004730100002)(4326007)(50986999)(229853001)(83506001)(5008740100001)(110136002)(33646002)(47776003)(230783001)(53416004)(81166006)(8676002)(586003)(2950100001)(6116002)(3846002)(77096005)(4001350100001)(86362001)(76176999)(54356999)(92566002)(23726003)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1699; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1699; 23:ZpsxCu7pgb65hF6fvYGq2dC6IG29px+PrHyJe6FCx?= =?us-ascii?Q?eZ0wMxQVUd1eQ77acBdkYqe8zj+J+cDAzHYkY5JvPsh7bHrah9ASHdlfMFMo?= =?us-ascii?Q?3oNsCiMoS6NcTXIY6Kkhdq9JrDtXbMztmw73UheJCcMCSqyym3tO+5K+PjFk?= =?us-ascii?Q?q1gPdjUi3YYgfSjhR0ikTtFy7/M5MLtujbF6Z1Dxmjotb2bYIemtOBwgnW6b?= =?us-ascii?Q?KE05iOqsdNBt8HQLXOl1sCHjTFJCrogVCY5XwhbzuO2mFD/O6cE+qQHj7/Bj?= =?us-ascii?Q?xbuW5FtwkfoB55fWpSzZOu9oL5+R5xJGc8RwJmDy+a/mqCzG119hWCHUAkqX?= =?us-ascii?Q?F5qn1JsNZuy1y/JngHoFpJPhbHeSXP/HHxjaawhT8bBCQ9HbuP7pLoXuhS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XASwFQ6Txg=; 7:ZgKFQ/OBsj0H00bj09k0p2s2u1/np2IEndnt8zU+B1n9jgTfh7SjG0vWQ3jWlp6s2P+Cs5DQLxkuRXfKocM+YWFpRC7RqnCIspGnPMCNt7zdTe0mgMGVrXcuM+xqRcPQFwpBgzIX8EiGqepqeEgETIFD6Ek2ocCssYLO3a0UCncDK6/pnTGXg1Ikt3X6FmvV; 20:gm4YhwrSq0FqxjCYH2GvfKO3tFnNkU/I15UG0SXXCQM19dmSiwdnp9JEksD1m3qzjUZnypljmSFP/3vQNIXNRl8lX2kW35qZn/b+yTVH3efEwh2wmNHVn19aT/i1QuVSVobyvcJylh6wfIivu7CHQpuG1/gO68AiXAnwv1LXzR4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2016 09:03:00.2136 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1699 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto simple-card needs to get its dai name and endpoint node. This patch makes it simple style standard Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 19 ++++++++++++++++++ sound/soc/generic/simple-card-utils.c | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index b8a8649..1a77d72 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -46,4 +46,23 @@ int asoc_simple_card_parse_clk(struct device_node *port_np, struct device_node *endpoint_np, struct asoc_simple_dai *simple_dai); +#define asoc_simple_card_parse_cpu(port_np, dai_link, \ + list_name, cells_name, is_single_link) \ + asoc_simple_card_parse_endpoint(port_np, &dai_link->cpu_of_node, \ + &dai_link->cpu_dai_name, list_name, cells_name, is_single_link) +#define asoc_simple_card_parse_codec(port_np, dai_link, \ + list_name, cells_name) \ + asoc_simple_card_parse_endpoint(port_np, &dai_link->codec_of_node, \ + &dai_link->codec_dai_name, list_name, cells_name, NULL) +#define asoc_simple_card_parse_platform(port_np, dai_link, \ + list_name, cells_name) \ + asoc_simple_card_parse_endpoint(port_np, &dai_link->platform_of_node, \ + NULL, list_name, cells_name, NULL) +int asoc_simple_card_parse_endpoint(struct device_node *port_np, + struct device_node **endpoint_np, + const char **dai_name, + const char *list_name, + const char *cells_name, + int *is_single_links); + #endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index dbf4b00..a3d917d 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -172,3 +172,41 @@ int asoc_simple_card_parse_clk(struct device_node *port_np, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk); + +int asoc_simple_card_parse_endpoint(struct device_node *port_np, + struct device_node **endpoint_np, + const char **dai_name, + const char *list_name, + const char *cells_name, + int *is_single_link) +{ + struct of_phandle_args args; + int ret; + + if (!port_np) + return 0; + + /* + * Get node via "sound-dai = <&phandle port>" + * it will be used as xxx_of_node on soc_bind_dai_link() + */ + ret = of_parse_phandle_with_args(port_np, + list_name, cells_name, 0, &args); + if (ret) + return ret; + + /* Get dai->name */ + if (dai_name) { + ret = snd_soc_of_get_dai_name(port_np, dai_name); + if (ret < 0) + return ret; + } + + *endpoint_np = args.np; + + if (is_single_link) + *is_single_link = !args.args_count; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_endpoint);