From: Simon Trimmer <simont@opensource.cirrus.com>
To: <broonie@kernel.org>, <lgirdwood@gmail.com>
Cc: <alsa-devel@alsa-project.org>, <patches@opensource.cirrus.com>,
<linux-kernel@vger.kernel.org>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Simon Trimmer <simont@opensource.cirrus.com>
Subject: [PATCH 02/16] ASoC: wm_adsp: Move check for control existence
Date: Mon, 13 Sep 2021 17:00:43 +0100 [thread overview]
Message-ID: <20210913160057.103842-3-simont@opensource.cirrus.com> (raw)
In-Reply-To: <20210913160057.103842-1-simont@opensource.cirrus.com>
From: Charles Keepax <ckeepax@opensource.cirrus.com>
Checking earlier in the function if a control already exists avoids
superfluous string construction and also prepares for future
refactoring.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Simon Trimmer <simont@opensource.cirrus.com>
---
sound/soc/codecs/wm_adsp.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index f5db6e3b9f60..b300af6fdd41 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1422,6 +1422,19 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,
const char *region_name;
int ret;
+ list_for_each_entry(ctl, &dsp->ctl_list, list) {
+ if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] &&
+ ctl->alg_region.alg == alg_region->alg &&
+ ctl->alg_region.type == alg_region->type) {
+ if ((!subname && !ctl->subname) ||
+ (subname && !strncmp(ctl->subname, subname, ctl->subname_len))) {
+ if (!ctl->enabled)
+ ctl->enabled = 1;
+ return 0;
+ }
+ }
+ }
+
region_name = wm_adsp_mem_region_name(alg_region->type);
if (!region_name) {
adsp_err(dsp, "Unknown region type: %d\n", alg_region->type);
@@ -1462,14 +1475,6 @@ static int wm_adsp_create_control(struct wm_adsp *dsp,
" %.*s", subname_len - skip, subname + skip);
}
- list_for_each_entry(ctl, &dsp->ctl_list, list) {
- if (!strcmp(ctl->name, name)) {
- if (!ctl->enabled)
- ctl->enabled = 1;
- return 0;
- }
- }
-
ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
if (!ctl)
return -ENOMEM;
--
2.33.0
next prev parent reply other threads:[~2021-09-13 16:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 16:00 [PATCH 00/16] add driver to support firmware loading on Cirrus Logic DSPs Simon Trimmer
2021-09-13 16:00 ` [PATCH 01/16] ASoC: wm_adsp: Remove use of snd_ctl_elem_type_t Simon Trimmer
2021-09-13 16:00 ` Simon Trimmer [this message]
2021-09-13 16:00 ` [PATCH 03/16] ASoC: wm_adsp: Switch to using wm_coeff_read_ctrl for compressed buffers Simon Trimmer
2021-09-13 16:00 ` [PATCH 04/16] ASoC: wm_adsp: Cancel ongoing work when removing controls Simon Trimmer
2021-09-13 16:00 ` [PATCH 05/16] ASoC: wm_adsp: Rename generic DSP support Simon Trimmer
2021-09-13 16:00 ` [PATCH 06/16] ASoC: wm_adsp: Introduce cs_dsp logging macros Simon Trimmer
2021-09-13 16:00 ` [PATCH 07/16] ASoC: wm_adsp: Separate some ASoC and generic functions Simon Trimmer
2021-09-13 16:00 ` [PATCH 08/16] ASoC: wm_adsp: Split DSP power operations into helper functions Simon Trimmer
2021-09-13 16:00 ` [PATCH 09/16] ASoC: wm_adsp: Move sys_config_size to wm_adsp Simon Trimmer
2021-09-13 16:00 ` [PATCH 10/16] ASoC: wm_adsp: Separate generic cs_dsp_coeff_ctl handling Simon Trimmer
2021-09-13 16:00 ` [PATCH 11/16] ASoC: wm_adsp: Move check of dsp->running to better place Simon Trimmer
2021-09-13 16:00 ` [PATCH 12/16] ASoC: wm_adsp: Pass firmware names as parameters when starting DSP core Simon Trimmer
2021-09-13 16:00 ` [PATCH 13/16] ASoC: wm_adsp: move firmware loading to client Simon Trimmer
2021-09-13 16:00 ` [PATCH 14/16] ASoC: wm_adsp: Split out struct cs_dsp from struct wm_adsp Simon Trimmer
2021-09-13 16:00 ` [PATCH 15/16] ASoC: wm_adsp: Separate wm_adsp specifics in cs_dsp_client_ops Simon Trimmer
2021-09-13 16:00 ` [PATCH 16/16] firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs Simon Trimmer
2021-09-27 17:45 ` [PATCH 00/16] " Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210913160057.103842-3-simont@opensource.cirrus.com \
--to=simont@opensource.cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).