From patchwork Wed Jan 12 17:00:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 12711060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 72F14C433F5 for ; Wed, 12 Jan 2022 09:02: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 9139F1942; Wed, 12 Jan 2022 10:01:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9139F1942 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641978130; bh=fNDyuJNFxqbDCtXCa0hZ3Ve+knlSigICfUw72BmANY8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SrMbBXF7NcHY4wp1zNQoW/LQCl7X3c03MOD6BdADCbJ6BqNPpIm3tjzTWHNr/P/7X 4zIhEyJreciKRjK7SVxNoXC+5QLBv/sOO4P+CxfB73jor8au6R8fXh19L/9QGwNtXr 8VVxd96xFZZnONrvk1CHqBuutLxnPwAgJD9nV0u8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B76CBF8026A; Wed, 12 Jan 2022 10:00:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8A78BF802BE; Wed, 12 Jan 2022 10:00:47 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6C04EF8025E for ; Wed, 12 Jan 2022 10:00:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6C04EF8025E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gvcML/ZB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641978042; x=1673514042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fNDyuJNFxqbDCtXCa0hZ3Ve+knlSigICfUw72BmANY8=; b=gvcML/ZB/a7IffamSaeq4v9Vx4xg2KVZCDVWyHxBvfbj3GYvCSmFXg/I imvBFMMP6Vetsfef3Eon/oKMFD6J6ed8ufHck5S+/gKjU2yg6iP6IH/sG fxgnZt9RqvZVcLziBeslgA9bnuc319sX2vfThRinrMZYaKzf08vFDoR/K 6zEjOobEUujtnJMdaBA81cNvcf/x4SO+XveWCt2uVKRag2NG2LFJUwDvd jRYGE4ifKYsZTNV4FFNZLLwLtu+BkbIVFTEzfHhOpjH7NCnodkrehFOmz qOrVfuEdMr4BZ2jFVyrRsjtV8XcoOSpONPQC2NvBCmOqGTMkTOWdmMT5R w==; X-IronPort-AV: E=McAfee;i="6200,9189,10224"; a="223674373" X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="223674373" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2022 01:00:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="691318361" Received: from dev2.igk.intel.com ([10.237.148.94]) by orsmga005.jf.intel.com with ESMTP; 12 Jan 2022 01:00:36 -0800 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Liam Girdwood , Mark Brown , Takashi Iwai Subject: [PATCH v2 1/3] ASoC: topology: Remove superfluous error prints Date: Wed, 12 Jan 2022 18:00:28 +0100 Message-Id: <20220112170030.569712-2-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220112170030.569712-1-amadeuszx.slawinski@linux.intel.com> References: <20220112170030.569712-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Cc: Cezary Rojewski , =?utf-8?q?Amadeusz_S=C5=82a?= =?utf-8?q?wi=C5=84ski?= , Pierre-Louis Bossart , alsa-devel@alsa-project.org 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" soc_tplg_check_elem_count(), already prints an error when applicable, so there is no need to print another one. Also clean up alignment of arguments in if, so there is no confusion about what is checked and what is executed if condition is true. Signed-off-by: Amadeusz Sławiński Reviewed-by: Cezary Rojewski Reviewed-by: Pierre-Louis Bossart --- sound/soc/soc-topology.c | 44 ++++++++++------------------------------ 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 078e1dc19ca6..e0f72ddd72c1 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -685,12 +685,9 @@ static int soc_tplg_dbytes_create(struct soc_tplg *tplg, unsigned int count, int err = 0; if (soc_tplg_check_elem_count(tplg, - sizeof(struct snd_soc_tplg_bytes_control), count, - size, "mixer bytes")) { - dev_err(tplg->dev, "ASoC: Invalid count %d for byte control\n", - count); + sizeof(struct snd_soc_tplg_bytes_control), + count, size, "mixer bytes")) return -EINVAL; - } for (i = 0; i < count; i++) { be = (struct snd_soc_tplg_bytes_control *)tplg->pos; @@ -763,13 +760,9 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, unsigned int count, int err = 0; if (soc_tplg_check_elem_count(tplg, - sizeof(struct snd_soc_tplg_mixer_control), - count, size, "mixers")) { - - dev_err(tplg->dev, "ASoC: invalid count %d for controls\n", - count); + sizeof(struct snd_soc_tplg_mixer_control), + count, size, "mixers")) return -EINVAL; - } for (i = 0; i < count; i++) { mc = (struct snd_soc_tplg_mixer_control *)tplg->pos; @@ -927,13 +920,9 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, unsigned int count, int err = 0; if (soc_tplg_check_elem_count(tplg, - sizeof(struct snd_soc_tplg_enum_control), - count, size, "enums")) { - - dev_err(tplg->dev, "ASoC: invalid count %d for enum controls\n", - count); + sizeof(struct snd_soc_tplg_enum_control), + count, size, "enums")) return -EINVAL; - } for (i = 0; i < count; i++) { ec = (struct snd_soc_tplg_enum_control *)tplg->pos; @@ -1111,13 +1100,9 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, count = le32_to_cpu(hdr->count); if (soc_tplg_check_elem_count(tplg, - sizeof(struct snd_soc_tplg_dapm_graph_elem), - count, le32_to_cpu(hdr->payload_size), "graph")) { - - dev_err(tplg->dev, "ASoC: invalid count %d for DAPM routes\n", - count); + sizeof(struct snd_soc_tplg_dapm_graph_elem), + count, le32_to_cpu(hdr->payload_size), "graph")) return -EINVAL; - } dev_dbg(tplg->dev, "ASoC: adding %d DAPM routes for index %d\n", count, hdr->index); @@ -1965,11 +1950,8 @@ static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg, if (soc_tplg_check_elem_count(tplg, size, count, le32_to_cpu(hdr->payload_size), - "PCM DAI")) { - dev_err(tplg->dev, "ASoC: invalid count %d for PCM DAI elems\n", - count); + "PCM DAI")) return -EINVAL; - } for (i = 0; i < count; i++) { pcm = (struct snd_soc_tplg_pcm *)tplg->pos; @@ -2243,14 +2225,10 @@ static int soc_tplg_link_elems_load(struct soc_tplg *tplg, return -EINVAL; } - if (soc_tplg_check_elem_count(tplg, - size, count, + if (soc_tplg_check_elem_count(tplg, size, count, le32_to_cpu(hdr->payload_size), - "physical link config")) { - dev_err(tplg->dev, "ASoC: invalid count %d for physical link elems\n", - count); + "physical link config")) return -EINVAL; - } /* config physical DAI links */ for (i = 0; i < count; i++) { From patchwork Wed Jan 12 17:00:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 12711061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 39294C433F5 for ; Wed, 12 Jan 2022 09:02:27 +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 3FA8E195A; Wed, 12 Jan 2022 10:01:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3FA8E195A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641978145; bh=+LNZHxxl5hhVgyY0XAKkh0uPwdUOs8jU5euZhrYD8Z0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pmrh7QYsB4BPPxXkJLJ6DWKi25KIM+wK6EjyyVcC0b8RMpx7PrVAsmqBq7M/YThTg 8G4OSQfV0YUqgsGNiwGtwuNrj4VV4x8RN8JYAmlrZLcon57YyWk65M6e3rMDlJkwfh ZVI+3Z6w3tA/3B6dmONYOBfvCaTU4LlI8u4q/VQ4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 45AD9F804FB; Wed, 12 Jan 2022 10:00:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 97267F80054; Wed, 12 Jan 2022 10:00:47 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A4764F8026A for ; Wed, 12 Jan 2022 10:00:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A4764F8026A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ReGeui0R" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641978042; x=1673514042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+LNZHxxl5hhVgyY0XAKkh0uPwdUOs8jU5euZhrYD8Z0=; b=ReGeui0RP6H1ECTbNrtHfIb2XZyoGxQhZ1Hbfo7TGV0M8W2El39YcS4x 2t841NSDNsGLOuWs1xOmwjSTMwW5qyOB6D5GBSKx0F6o/M7faonyJRJrU +uKWJp4sgFJHGF9W4Wonjf7IohZ/XO8ZF1VA5pkCOap00cILwhi3umnIw egK3CsZITLtBY5WSE+Ef3kJDusP17aFXXNFUQEwrvA6YrN6OOTRuAY/sZ rCER+/yzhQivyMApKKzDeEqBrbnlTAoD8N61Z+0UNSZXfyCikyMgnkfz+ GuVGhbXkegKv/Cs2mSAfD7IyRV50Nx+6/o8oM9JNxTuzz7kZ+ZyJ4ipRv A==; X-IronPort-AV: E=McAfee;i="6200,9189,10224"; a="223674382" X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="223674382" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2022 01:00:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="691318378" Received: from dev2.igk.intel.com ([10.237.148.94]) by orsmga005.jf.intel.com with ESMTP; 12 Jan 2022 01:00:39 -0800 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Liam Girdwood , Mark Brown , Takashi Iwai Subject: [PATCH v2 2/3] ASoC: topology: Allow TLV control to be either read or write Date: Wed, 12 Jan 2022 18:00:29 +0100 Message-Id: <20220112170030.569712-3-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220112170030.569712-1-amadeuszx.slawinski@linux.intel.com> References: <20220112170030.569712-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Cc: Cezary Rojewski , =?utf-8?q?Amadeusz_S=C5=82a?= =?utf-8?q?wi=C5=84ski?= , Pierre-Louis Bossart , alsa-devel@alsa-project.org 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" There is no reason to force readwrite access on TLV controls. It can be either read, write or both. This is further evidenced in code where it performs following checks: if ((k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) && !sbe->get) return -EINVAL; if ((k->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) && !sbe->put) return -EINVAL; Fixes: 1a3232d2f61d ("ASoC: topology: Add support for TLV bytes controls") Signed-off-by: Amadeusz Sławiński Reviewed-by: Cezary Rojewski Reviewed-by: Pierre-Louis Bossart --- sound/soc/soc-topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index e0f72ddd72c1..9d24184f85f9 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -512,7 +512,8 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, if (le32_to_cpu(hdr->ops.info) == SND_SOC_TPLG_CTL_BYTES && k->iface & SNDRV_CTL_ELEM_IFACE_MIXER - && k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE + && (k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ + || k->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) && k->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { struct soc_bytes_ext *sbe; struct snd_soc_tplg_bytes_control *be; From patchwork Wed Jan 12 17:00:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 12711062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4C88FC433EF for ; Wed, 12 Jan 2022 09:02:45 +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 84B621A98; Wed, 12 Jan 2022 10:01:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 84B621A98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641978163; bh=OOctC/WJvrvUusIpbqZbeVs1ealVVe3KRmSoy/SYgoc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V614o32uT4SmMPhutzE6NChkd6/iFsEy2HY3qLSwkAH5VfbRYbjuI+xmlFLWfmxvJ 8XSKDO+qWe+HbY44a6lYVBLIi8vo3mJenOAKBHbYVq5z/vRjkEJkKnTRBcvNVesGHc YmR7TJoz1DnXpUkAUiw0yORluiFqR9roWp/g1b4E= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 121E4F80510; Wed, 12 Jan 2022 10:00:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3B8D1F80511; Wed, 12 Jan 2022 10:00:53 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B67CCF8025E for ; Wed, 12 Jan 2022 10:00:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B67CCF8025E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="guQGL2ct" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641978047; x=1673514047; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OOctC/WJvrvUusIpbqZbeVs1ealVVe3KRmSoy/SYgoc=; b=guQGL2ctHfvZhueaT/Fv8hYybJgq3MXOEhzKO8T6CzlDsb3KW/3PEn0j fi+4L85eA/WWTrxdG3TG9FvZ8iGATb3lLEc1ZLr5CSGVQncn8tiy72Oto d9Wz57xrQ/OrJneEI3LqqaAmc3wqKf4Li+iZ6CEV3L2Ntb56tzHQ3GaUT a8kwHZWbT0mhWveVxip/RaYfweRNCjmbmg5/aSji8EgpR1JZBrmSVqdWp 7johnaFbgSNhrrWwQtDUZKQZG3hMpIkTeU5laDEhqZyTjSC3JPCaCMSDk ffreMZ9XPHywhh7mVSCLbhRWJ1I0fBAlryiD5SGBs7s8oGR6xs06jTaqL g==; X-IronPort-AV: E=McAfee;i="6200,9189,10224"; a="223674394" X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="223674394" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2022 01:00:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,282,1635231600"; d="scan'208";a="691318397" Received: from dev2.igk.intel.com ([10.237.148.94]) by orsmga005.jf.intel.com with ESMTP; 12 Jan 2022 01:00:41 -0800 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Liam Girdwood , Mark Brown , Takashi Iwai Subject: [PATCH v2 3/3] ASoC: topology: Optimize soc_tplg_dapm_graph_elems_load behavior Date: Wed, 12 Jan 2022 18:00:30 +0100 Message-Id: <20220112170030.569712-4-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220112170030.569712-1-amadeuszx.slawinski@linux.intel.com> References: <20220112170030.569712-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Cc: Cezary Rojewski , =?utf-8?q?Amadeusz_S=C5=82a?= =?utf-8?q?wi=C5=84ski?= , Pierre-Louis Bossart , alsa-devel@alsa-project.org 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" Before commit "ASoC: topology: Change allocations to resource managed" soc_tplg_dapm_graph_elems_load() used to free routes on error. During migration to managed allocations the routes table was left as is, but looking at it again it is unnecessary, so remove routes table and just keep pointer to DAPM route currently being set up. Also remove outdated comments which keep describing old behavior of remove_route() freeing memory. While it still does some cleanup, it leaves freeing memory to framework. Fixes: ff9226224437 ("ASoC: topology: Change allocations to resource managed") Signed-off-by: Amadeusz Sławiński Reviewed-by: Cezary Rojewski Reviewed-by: Pierre-Louis Bossart --- sound/soc/soc-topology.c | 56 ++++++++++------------------------------ 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 9d24184f85f9..6c7dc571c006 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1094,7 +1094,7 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, { struct snd_soc_dapm_context *dapm = &tplg->comp->dapm; struct snd_soc_tplg_dapm_graph_elem *elem; - struct snd_soc_dapm_route **routes; + struct snd_soc_dapm_route *route; int count, i; int ret = 0; @@ -1108,24 +1108,10 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, dev_dbg(tplg->dev, "ASoC: adding %d DAPM routes for index %d\n", count, hdr->index); - /* allocate memory for pointer to array of dapm routes */ - routes = kcalloc(count, sizeof(struct snd_soc_dapm_route *), - GFP_KERNEL); - if (!routes) - return -ENOMEM; - - /* - * allocate memory for each dapm route in the array. - * This needs to be done individually so that - * each route can be freed when it is removed in remove_route(). - */ for (i = 0; i < count; i++) { - routes[i] = devm_kzalloc(tplg->dev, sizeof(*routes[i]), GFP_KERNEL); - if (!routes[i]) + route = devm_kzalloc(tplg->dev, sizeof(*route), GFP_KERNEL); + if (!route) return -ENOMEM; - } - - for (i = 0; i < count; i++) { elem = (struct snd_soc_tplg_dapm_graph_elem *)tplg->pos; tplg->pos += sizeof(struct snd_soc_tplg_dapm_graph_elem); @@ -1146,46 +1132,32 @@ static int soc_tplg_dapm_graph_elems_load(struct soc_tplg *tplg, break; } - routes[i]->source = elem->source; - routes[i]->sink = elem->sink; + route->source = elem->source; + route->sink = elem->sink; /* set to NULL atm for tplg users */ - routes[i]->connected = NULL; + route->connected = NULL; if (strnlen(elem->control, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) == 0) - routes[i]->control = NULL; + route->control = NULL; else - routes[i]->control = elem->control; + route->control = elem->control; /* add route dobj to dobj_list */ - routes[i]->dobj.type = SND_SOC_DOBJ_GRAPH; - routes[i]->dobj.ops = tplg->ops; - routes[i]->dobj.index = tplg->index; - list_add(&routes[i]->dobj.list, &tplg->comp->dobj_list); + route->dobj.type = SND_SOC_DOBJ_GRAPH; + route->dobj.ops = tplg->ops; + route->dobj.index = tplg->index; + list_add(&route->dobj.list, &tplg->comp->dobj_list); - ret = soc_tplg_add_route(tplg, routes[i]); + ret = soc_tplg_add_route(tplg, route); if (ret < 0) { dev_err(tplg->dev, "ASoC: topology: add_route failed: %d\n", ret); - /* - * this route was added to the list, it will - * be freed in remove_route() so increment the - * counter to skip it in the error handling - * below. - */ - i++; break; } /* add route, but keep going if some fail */ - snd_soc_dapm_add_routes(dapm, routes[i], 1); + snd_soc_dapm_add_routes(dapm, route, 1); } - /* - * free pointer to array of dapm routes as this is no longer needed. - * The memory allocated for each dapm route will be freed - * when it is removed in remove_route(). - */ - kfree(routes); - return ret; }