From patchwork Wed Mar 11 18:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 11432463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D65B913 for ; Wed, 11 Mar 2020 18:06:30 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E82F20691 for ; Wed, 11 Mar 2020 18:06:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="t9VAyBm+"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KGUQqjtX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E82F20691 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 DC35C1679; Wed, 11 Mar 2020 19:05:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DC35C1679 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1583949987; bh=TZqe4ZtYQUmklWOXHOEpIq5uF4AXsMvZegYk3tGqNh8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=t9VAyBm+Zf68+TQ8RdWvmso93mtv/e6CEuSFF35/pur9WchC6B8MDEg2WPmY6MM3v 1P2WY7GjYu3TBC37CQdCa5baI5Q/SxcKPvIcxW6eSz0pDvpPBr1D+poOG6Ab19/9+T qQVqSLqMaOlsKYy34dHCF/fMiOiGUmQJenPikqqM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E50A9F80217; Wed, 11 Mar 2020 19:04:50 +0100 (CET) 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 79BEAF801F7; Wed, 11 Mar 2020 19:04:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,SURBL_BLOCKED,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DCC5BF800BE for ; Wed, 11 Mar 2020 19:04:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DCC5BF800BE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KGUQqjtX" Received: by mail-wm1-x344.google.com with SMTP id f7so3171561wml.4 for ; Wed, 11 Mar 2020 11:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ko+f04MVdRtDW1tJPAYxq3VR8XAY3gAswAGYqmbv10w=; b=KGUQqjtXCiM9TTaRqOalBpsoGhAuqWfLxdC6jGMu+jkWXmhHu++/mDWPhjwg5VTICC hWegtEImHiXCNZaoTi3Laup0KYsxQ2k085mIEQmS6D2JiSrZYeJY5ZjdXgIALRpbeSDr Fd+uWYZRl7wPw/zZbTgx1YmHlc+Z8dCeXcGDEljSjVACdlcDLEgRcFGnzQZi5vcCO6Ij QNcVufk66xuZss6cNQ4zuGxvxXCYHCbp/JY+Y/BYbHNhbuUOC+wa0MPGMlNIQPc2yEb+ ucOGh5mhxY0yKALnJieG8fEuUWBM6rHgnePfPMBG7TUI20LlJVyodk8vIYBIOtvt8i9g ScXw== 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=Ko+f04MVdRtDW1tJPAYxq3VR8XAY3gAswAGYqmbv10w=; b=M2pqvc/xFQJd6FCVEampeM0AuC1JOMZz1t+zTWUhyT0z4k9ukJ5SyR5hvq/Q4mKlin b4KYGKUHtGxO7Uj2+F69+FxloPC3HFLMhjRE2sAgmpUuFvNKXXEwu70pq8qPvSiUQwSG T+4f5JrRN92XdVQtwxi9hlJ3GD1bPLm4yl59tnu1Akt3mFP/4gakjcgs4G+HXl37DEWI f+5qHp308DK6VlKMhyoISKpESv3cr9tGQ5xzFvZR3mMQPUixqG5yXPfNx8rHXUCzXfTl vg72eAmNc50V0Mfs6m6BpgQ8+Wsz6M/y1YFhlgshObN3qZoxNCmOYG3Aii79b6grgANF 3C7g== X-Gm-Message-State: ANhLgQ30SVs9O669nYirgDNfyTWDzijKdxg6s88hzzc1BpjlKYh/9a3Y 8h2kOlAExgiW3075D7ptTBCI6Q== X-Google-Smtp-Source: ADFU+vvVrTaAUu7ON5vFK7p0ja0xplS1TC2dk+nm4D+UFMEJx/tKEtHgJH5iT2cEGJuo+5TZgIq5fg== X-Received: by 2002:a1c:2045:: with SMTP id g66mr4772885wmg.15.1583949883888; Wed, 11 Mar 2020 11:04:43 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id z11sm8997840wmd.47.2020.03.11.11.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 11:04:43 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 1/2] ASoC: qdsp6: q6asm-dai: only enable dais from device tree Date: Wed, 11 Mar 2020 18:04:21 +0000 Message-Id: <20200311180422.28363-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200311180422.28363-1-srinivas.kandagatla@linaro.org> References: <20200311180422.28363-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla , lgirdwood@gmail.com 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" Existing code enables all the playback and capture dais even if there is no device tree entry. This can lead to un-necessary dais in the system which will never be used. So honour whats specfied in device tree. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6asm-dai.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c index c0d422d0ab94..8b48815ff918 100644 --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -69,6 +69,8 @@ struct q6asm_dai_rtd { }; struct q6asm_dai_data { + struct snd_soc_dai_driver *dais; + int num_dais; long long int sid; }; @@ -889,7 +891,7 @@ static const struct snd_soc_component_driver q6asm_fe_dai_component = { .compr_ops = &q6asm_dai_compr_ops, }; -static struct snd_soc_dai_driver q6asm_fe_dais[] = { +static struct snd_soc_dai_driver q6asm_fe_dais_template[] = { Q6ASM_FEDAI_DRIVER(1), Q6ASM_FEDAI_DRIVER(2), Q6ASM_FEDAI_DRIVER(3), @@ -903,10 +905,22 @@ static struct snd_soc_dai_driver q6asm_fe_dais[] = { static int of_q6asm_parse_dai_data(struct device *dev, struct q6asm_dai_data *pdata) { - static struct snd_soc_dai_driver *dai_drv; + struct snd_soc_dai_driver *dai_drv; struct snd_soc_pcm_stream empty_stream; struct device_node *node; - int ret, id, dir; + int ret, id, dir, idx = 0; + + + pdata->num_dais = of_get_child_count(dev->of_node); + if (!pdata->num_dais) { + dev_err(dev, "No dais found in DT\n"); + return -EINVAL; + } + + pdata->dais = devm_kcalloc(dev, pdata->num_dais, sizeof(*dai_drv), + GFP_KERNEL); + if (!pdata->dais) + return -ENOMEM; memset(&empty_stream, 0, sizeof(empty_stream)); @@ -917,7 +931,8 @@ static int of_q6asm_parse_dai_data(struct device *dev, continue; } - dai_drv = &q6asm_fe_dais[id]; + dai_drv = &pdata->dais[idx++]; + *dai_drv = q6asm_fe_dais_template[id]; ret = of_property_read_u32(node, "direction", &dir); if (ret) @@ -955,11 +970,12 @@ static int q6asm_dai_probe(struct platform_device *pdev) dev_set_drvdata(dev, pdata); - of_q6asm_parse_dai_data(dev, pdata); + rc = of_q6asm_parse_dai_data(dev, pdata); + if (rc) + return rc; return devm_snd_soc_register_component(dev, &q6asm_fe_dai_component, - q6asm_fe_dais, - ARRAY_SIZE(q6asm_fe_dais)); + pdata->dais, pdata->num_dais); } static const struct of_device_id q6asm_dai_device_id[] = {