From patchwork Wed Jul 24 09:38:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricard Wanderlof X-Patchwork-Id: 11056523 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 72D93184E for ; Wed, 24 Jul 2019 09:47:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6441128514 for ; Wed, 24 Jul 2019 09:47:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58B2F28757; Wed, 24 Jul 2019 09:47:13 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DC9C28514 for ; Wed, 24 Jul 2019 09:47:12 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C44A91A96; Wed, 24 Jul 2019 11:38:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C44A91A96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1563961185; bh=9Rw0mj8KXSOY4zctRyDNzKZG/t93s0uiXIbdNK6d25w=; h=Date:From:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=umEmPHWbz2l3KtIL89ENcbl7eOkhooEe69Cl8DBUYEpBihKt/4LLC6bsjsIRFBCqv 9WCky4/nUgxlXbj3WD7BEMFlE2MQMbDKmUQLui9F3kTFQCaoPgCPWTosatU73Nbq1U QbJO868Hy2F4tm8mpGztxh+cpLkq1mTq+SpYswqU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3FFB0F803D1; Wed, 24 Jul 2019 11:38:55 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id D4BACF803D7; Wed, 24 Jul 2019 11:38:53 +0200 (CEST) Received: from bastet.se.axis.com (bastet.se.axis.com [195.60.68.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 760BCF800E8 for ; Wed, 24 Jul 2019 11:38:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 760BCF800E8 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 5805318521; Wed, 24 Jul 2019 11:38:50 +0200 (CEST) X-Axis-User: NO X-Axis-NonUser: YES X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id b75yz--fjsbb; Wed, 24 Jul 2019 11:38:49 +0200 (CEST) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id 9FCF41851A; Wed, 24 Jul 2019 11:38:49 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D46E1A070; Wed, 24 Jul 2019 11:38:49 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81CF41A06D; Wed, 24 Jul 2019 11:38:49 +0200 (CEST) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder02.se.axis.com (Postfix) with ESMTP; Wed, 24 Jul 2019 11:38:49 +0200 (CEST) Received: from XBOX03.axis.com (xbox03.axis.com [10.0.5.17]) by thoth.se.axis.com (Postfix) with ESMTP id 75D8E3092; Wed, 24 Jul 2019 11:38:49 +0200 (CEST) Received: from lnxricardw1.se.axis.com (10.0.5.60) by XBOX03.axis.com (10.0.5.17) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Wed, 24 Jul 2019 11:38:49 +0200 Date: Wed, 24 Jul 2019 11:38:44 +0200 From: Ricard Wanderlof X-X-Sender: ricardw@lnxricardw1.se.axis.com To: Mark Brown , Liam Girdwood Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-Originating-IP: [10.0.5.60] X-ClientProxiedBy: XBOX02.axis.com (10.0.5.16) To XBOX03.axis.com (10.0.5.17) X-TM-AS-GCONF: 00 Cc: alsa-devel Subject: [alsa-devel] [PATCH] ASoC: Fail card instantiation if DAI format setup fails X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP If the DAI format setup fails, there is no valid communication format between CPU and CODEC, so fail card instantiation, rather than continue with a card that will most likely not function properly. Signed-off-by: Ricard Wanderlof --- I've had the problem of a sound card coming up even though an incorrect DAI format was selected in the devicetree, apparently caused by not checking the return value of snd_soc_runtime_set_dai_fmt() when the card is instantiated, with the result in this particular case that that the audio data was not transferred correctly (capture data was shifted one bit up). I'm unsure though if this is intentional, I can't think why it should be, since the DAI format is only set up at this time and not for instance later when a stream is enabled, but perhaps I'm missing something here. At any rate, with this patch, the card does not come up under these circumstances. The error message from snd_soc_runtime_set_dai_fmt() is still printed to the kernel log so it's possible to see what the reason is. /Ricard sound/soc/soc-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7ecfe641ca46..06697b2d96b1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1511,8 +1511,11 @@ static int soc_probe_link_dais(struct snd_soc_card *card, } } - if (dai_link->dai_fmt) - snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); + if (dai_link->dai_fmt) { + ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt); + if (ret) + return ret; + } ret = soc_post_component_init(rtd, dai_link->name); if (ret)