From patchwork Thu Jun 27 12:13:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 11019571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D8A91580 for ; Thu, 27 Jun 2019 12:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E00328B06 for ; Thu, 27 Jun 2019 12:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5285528B17; Thu, 27 Jun 2019 12:14: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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D4F128B13 for ; Thu, 27 Jun 2019 12:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=X9p2SEwLWH+C/cCLaj2X2Ju7hNI/9Pu2lEKXqNPeS6s=; b=bXGpov1B/B35Go GyTatHs4XjNFyzv6wIWVfF5eSUSLDi40ULhm5aGbZGUTY3wwurI24L5DEq/Zx3OpPqJDWFmUfeu+K giJAayuPbpigeUNfyMih0Yu5NIjWMavTTDL++wZNORv42D6meVmsQC11MMBQWhBsbD5TdoMirZSYz tUyJv7jRRQgh7XhTQw5CriRKxMWaUq92OIsGzFKccGsKTICay7P2GvKehNsQIGt0fBKxnHZX3Lnti 5v5vB3aQZyD4lI1eWkNFWcCmEbQvabXrT6uE1ZLJW//tL5ImirNYtJHXdMh3Q1sLkQyaCRrgcuVAm u0rrU5OjoOD/v2dV8EsA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hgTHy-0004C7-7F; Thu, 27 Jun 2019 12:14:06 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hgTHu-00049p-HS for linux-amlogic@lists.infradead.org; Thu, 27 Jun 2019 12:14:03 +0000 Received: by mail-wm1-x344.google.com with SMTP id c66so5506614wmf.0 for ; Thu, 27 Jun 2019 05:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6dZUNh41e54wloGbD976gFDh/dh9Od8QCAeDEWTqPi0=; b=OngWCzsC9ReioQ2dB+3Si543jtwEMKbYjq/B6YLYPcItr0MZED1V2Dnrf1ipky90Xm 2iqnk1Q9oOnzku0hLU6IbIPk+Egc8yDD67sNL0VmwMMzUU6CWjk9wYoUOhtUyro6kaA2 x/kegG5rlAwYjSM9O5eUH2HiLieh6BIsN7bTxHpA+O0W4ef+8mzhbLP8T45X3vwagZ3Y 2zeBk3oPb43DvoPr30KaBrp0CTr4oLPqlx9RgjuNGnVfvlC2yVMbWuuALVF0uTIrL/Jy QcGya6qoe436hbQ2EZ06QZ3VYz3D6/Hnha2mc6zl9JCmqKAXP/jm6XI7aGTMuHjMXqrN FN5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6dZUNh41e54wloGbD976gFDh/dh9Od8QCAeDEWTqPi0=; b=BuMi4qmohj5o3SErRAXveOPS6oSFvU/Rnq6DMfq0aUlDDBdvn6RXXacnfGy5/mkRrB +xoFhLjma2mG9ahuvMAMdgfpItJlyo3OcfbZ1csTG21fQOjwnMWWaFflnlsu5Pc8XTEd yTfrZ6/gecunKPDBOtGnZxwHUIG3R64MAQwvp52PU+W5LbC5P4V8sc39Hi4xybl4HdBj 4uoq0alN8WR4zEMyVXQXfzIYO6EgUymQINSwr2egU0KmLkfJZwJ8UksuZ7wTqmwgOm/t Hi+vmwcr572/OKYe/r1a/GY7LXe/Kk4J/+BblZQorNoOwXYItG273i4xqmLZ8mD0iC7/ YxIw== X-Gm-Message-State: APjAAAV10v7DHozW5fyqPqwT6XSceV52xvt7s29JBy/I+3qaMDvhK4UB in+lubCnIS2EB8AVYkU06//5UA== X-Google-Smtp-Source: APXvYqza+Hvs5MtThW6KOFfdj04i4mvr0iJ5DAtXO9FQIkHVfLWq3VCCfUzX1vZSCuDoDWFEcBd7aA== X-Received: by 2002:a1c:c109:: with SMTP id r9mr3255675wmf.143.1561637640165; Thu, 27 Jun 2019 05:14:00 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id i11sm6160594wmi.33.2019.06.27.05.13.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 05:13:59 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Subject: [PATCH v2 1/2] ASoC: soc-core: defer card registration if codec component is missing Date: Thu, 27 Jun 2019 14:13:49 +0200 Message-Id: <20190627121350.21027-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190627121350.21027-1-jbrunet@baylibre.com> References: <20190627121350.21027-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190627_051402_576208_BE10884F X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, Jerome Brunet Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Like cpus and platforms, defer sound card initialization if the codec component is missing when initializing the dai_link Signed-off-by: Jerome Brunet --- sound/soc/soc-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 358f1fbf9a30..0ec1d7a59b24 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1064,12 +1064,20 @@ static int soc_init_dai_link(struct snd_soc_card *card, link->name); return -EINVAL; } + /* Codec DAI name must be specified */ if (!codec->dai_name) { dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n", link->name); return -EINVAL; } + + /* + * Defer card registration if codec component is not added to + * component list. + */ + if (!soc_find_component(codec)) + return -EPROBE_DEFER; } /* From patchwork Thu Jun 27 12:13:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 11019573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE6E21580 for ; Thu, 27 Jun 2019 12:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF2C028B0A for ; Thu, 27 Jun 2019 12:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D35A528894; Thu, 27 Jun 2019 12:14:09 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C85128894 for ; Thu, 27 Jun 2019 12:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TVoBjpsmCaIeXPTDN/g6Rr5g0E87RdD601USM7yjKtc=; b=o4K5nCaBb6d1zs 0W1MFx8tloYVRKWdX5kLekM849/emACk8MRTZbDma+pam5cwT26tRmsInaEFgz7hxqGwgp7KPM+K1 Psb4FqHJp8eEF8g4Gz2r/zL2fWWUWscnVEPKwJc8d0Y86Sbgf49s3ZwWlxxzuMOUf/QzGPC7cTS4P XXjwVgZn02LCb8yCozvFGZuEhW/QRH7h9rGqIweA1t7BlFf73iVyQnhlKyZhdB4VXUagXgDfbO1Ed JUN9uhSwxwcNxcPjUmYG1hr6/bulFxmHSYfZw+e55O+J3itKcggqI+xz5nVBSDdCl4AL6ivn9ZPMg GTiQ4WqSd6gp7iDjb7dA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hgTI0-0004EL-Tb; Thu, 27 Jun 2019 12:14:08 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hgTHu-0004A5-NY for linux-amlogic@lists.infradead.org; Thu, 27 Jun 2019 12:14:04 +0000 Received: by mail-wm1-x342.google.com with SMTP id x15so5505263wmj.3 for ; Thu, 27 Jun 2019 05:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6PqH7FtXAyTVmgRsql/9Vt6uYwCKZA1EzRvgR9PRCkQ=; b=UhohxZSBhwVGzRN5sjpR2ypPIONf+8GU9/388Qyunz9WdEExkKcDyUXrjsD2j/7QLk i6uIVB+v9aetT6bkneXelTtWodDRCTjCeUFfPeMRtuxXN0X6wM3dXiS9WXaxkKt7sJXF yptlETEn8CDMz08vjnx/gIikHwQ/DNYwXqOyLY9z3xZHZcuos4UlnodAvrgpao0oV9iB 11L5dPCvpCGPyTj3gewwdoPHN+z6jUMNGq5ADkCmSsGo3u6gIu7ALtf/wqb2HPcz9Gdm KyuUhMBX+EO/uldm6thj+CLA5sHKQrjNg0ucRhQVprBCZRsTA1WIuaRZRYrdeNMlmJzs z6FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6PqH7FtXAyTVmgRsql/9Vt6uYwCKZA1EzRvgR9PRCkQ=; b=j06eWARsM9Qcmx+fwuXzLzLLiCxoYeutLu3i9gtPQMocRsZYr+/UD6ceE6MyyfIpdU O6Ypd3zwXrrQJwKaZ1Uj1QeB9t6qhQN8bmG3c9+8zu75cP7aTI6gqKyvE6WMzpSL3207 CCyYFxwh8aX7bhg0JL1WACpLeIxuwek1dktX8tTCEC69IdSE6QNATrG7Rp20TnKSrPIR BBCvXkPb5buJrp3erBW5jSnVN7jowvfeJd7Qs+Dywr1/v9Q8WfJmmp4jRnysnfyv2eix FIYlQ5ptWyluQImH9QdEt3R28EQc4daLeotlH1H+0dcl7dAu5mlqHNnDnKvq23E1XB8/ AkgA== X-Gm-Message-State: APjAAAUgvgLvVdgM+JUSyzDscXXcX/RNYgmGBaAlCnswHafN9CTDbyES S2cLJFIegJGxYRM/+Og9T6mPWg== X-Google-Smtp-Source: APXvYqy6mtChxwDtyR5Jh1xEngeE3SkTPccDJu6eNMVT6HXO76ZboMJZAJ6y2aPsXhzlNUEe4WNiNg== X-Received: by 2002:a7b:c450:: with SMTP id l16mr3239638wmi.0.1561637641154; Thu, 27 Jun 2019 05:14:01 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id i11sm6160594wmi.33.2019.06.27.05.14.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 05:14:00 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Subject: [PATCH v2 2/2] ASoC: soc-core: support dai_link with platforms_num != 1 Date: Thu, 27 Jun 2019 14:13:50 +0200 Message-Id: <20190627121350.21027-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190627121350.21027-1-jbrunet@baylibre.com> References: <20190627121350.21027-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190627_051402_872979_2B0C7C46 X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Kuninori Morimoto , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, Jerome Brunet Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support platforms_num != 1 in dai_link. Initially, the main purpose of this change was to make the platform optional in the dai_link, instead of inserting the dummy platform driver. This particular case had just been solved by Kuninori Morimoto with commit 1d7689892878 ("ASoC: soc-core: allow no Platform on dai_link"). However, this change may still be useful for those who need multiple platform components on a single dai_link (it solves one of the FIXME note in soc-core) Acked-by: Kuninori Morimoto Signed-off-by: Jerome Brunet --- include/sound/soc.h | 6 +++++ sound/soc/soc-core.c | 59 ++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 64405cdab8bb..4e8071269639 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -997,6 +997,12 @@ struct snd_soc_dai_link { ((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \ (i)++) +#define for_each_link_platforms(link, i, platform) \ + for ((i) = 0; \ + ((i) < link->num_platforms) && \ + ((platform) = &link->platforms[i]); \ + (i)++) + /* * Sample 1 : Single CPU/Codec/Platform * diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 0ec1d7a59b24..c17d2f73fa71 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -887,7 +887,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai_link_component *codecs; + struct snd_soc_dai_link_component *codec, *platform; struct snd_soc_component *component; int i; @@ -917,13 +917,14 @@ static int soc_bind_dai_link(struct snd_soc_card *card, /* Find CODEC from registered CODECs */ rtd->num_codecs = dai_link->num_codecs; - for_each_link_codecs(dai_link, i, codecs) { - rtd->codec_dais[i] = snd_soc_find_dai(codecs); + for_each_link_codecs(dai_link, i, codec) { + rtd->codec_dais[i] = snd_soc_find_dai(codec); if (!rtd->codec_dais[i]) { dev_info(card->dev, "ASoC: CODEC DAI %s not registered\n", - codecs->dai_name); + codec->dai_name); goto _err_defer; } + snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component); } @@ -931,12 +932,13 @@ static int soc_bind_dai_link(struct snd_soc_card *card, rtd->codec_dai = rtd->codec_dais[0]; /* Find PLATFORM from registered PLATFORMs */ - for_each_component(component) { - if (!snd_soc_is_matching_component(dai_link->platforms, - component)) - continue; + for_each_link_platforms(dai_link, i, platform) { + for_each_component(component) { + if (!snd_soc_is_matching_component(platform, component)) + continue; - snd_soc_rtdcom_add(rtd, component); + snd_soc_rtdcom_add(rtd, component); + } } soc_add_pcm_runtime(card, rtd); @@ -1051,15 +1053,14 @@ static int soc_init_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link) { int i; - struct snd_soc_dai_link_component *codec; + struct snd_soc_dai_link_component *codec, *platform; for_each_link_codecs(link, i, codec) { /* * Codec must be specified by 1 of name or OF node, * not both or neither. */ - if (!!codec->name == - !!codec->of_node) { + if (!!codec->name == !!codec->of_node) { dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n", link->name); return -EINVAL; @@ -1080,36 +1081,24 @@ static int soc_init_dai_link(struct snd_soc_card *card, return -EPROBE_DEFER; } - /* - * Platform may be specified by either name or OF node, - * or no Platform. - * - * FIXME - * - * We need multi-platform support - */ - if (link->num_platforms > 0) { - - if (link->num_platforms > 1) { - dev_err(card->dev, - "ASoC: multi platform is not yet supported %s\n", - link->name); - return -EINVAL; - } - - if (link->platforms->name && link->platforms->of_node) { + for_each_link_platforms(link, i, platform) { + /* + * Platform may be specified by either name or OF node, but it + * can be left unspecified, then no components will be inserted + * in the rtdcom list + */ + if (!!platform->name == !!platform->of_node) { dev_err(card->dev, - "ASoC: Both platform name/of_node are set for %s\n", + "ASoC: Neither/both platform name/of_node are set for %s\n", link->name); return -EINVAL; } /* - * Defer card registartion if platform dai component is not - * added to component list. + * Defer card registration if platform component is not added to + * component list. */ - if ((link->platforms->of_node || link->platforms->name) && - !soc_find_component(link->platforms)) + if (!soc_find_component(platform)) return -EPROBE_DEFER; }