From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>, <perex@perex.cz>, <tiwai@suse.com>
Cc: <lgirdwood@gmail.com>, <linux-sound@vger.kernel.org>,
<patches@opensource.cirrus.com>
Subject: [PATCH v3 2/4] ASoC: soc-component: Add new snd_soc_component_get_kcontrol() helper
Date: Thu, 1 Aug 2024 11:04:11 +0100 [thread overview]
Message-ID: <20240801100413.1620481-2-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20240801100413.1620481-1-ckeepax@opensource.cirrus.com>
Add a new helper function that returns a kcontrol by name, but will
factor in the components name_prefix, to handle situations where
multiple components are present with the same controls.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
No change since v2.
Thanks,
Charles
include/sound/soc-component.h | 2 ++
sound/soc/soc-component.c | 16 ++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index ceca69b46a821..61534ac0edd1d 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -462,6 +462,8 @@ int snd_soc_component_force_enable_pin_unlocked(
const char *pin);
/* component controls */
+struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component,
+ const char * const ctl);
int snd_soc_component_notify_control(struct snd_soc_component *component,
const char * const ctl);
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 4d7c2e3c929a9..1c0971823fb4d 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -236,11 +236,10 @@ int snd_soc_component_force_enable_pin_unlocked(
}
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
-int snd_soc_component_notify_control(struct snd_soc_component *component,
- const char * const ctl)
+struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component,
+ const char * const ctl)
{
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
- struct snd_kcontrol *kctl;
/* When updating, change also snd_soc_dapm_widget_name_cmp() */
if (component->name_prefix)
@@ -248,7 +247,16 @@ int snd_soc_component_notify_control(struct snd_soc_component *component,
else
snprintf(name, ARRAY_SIZE(name), "%s", ctl);
- kctl = snd_soc_card_get_kcontrol(component->card, name);
+ return snd_soc_card_get_kcontrol(component->card, name);
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_get_kcontrol);
+
+int snd_soc_component_notify_control(struct snd_soc_component *component,
+ const char * const ctl)
+{
+ struct snd_kcontrol *kctl;
+
+ kctl = snd_soc_component_get_kcontrol(component, ctl);
if (!kctl)
return soc_component_ret(component, -EINVAL);
--
2.39.2
next prev parent reply other threads:[~2024-08-01 10:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 10:04 [PATCH v3 1/4] ASoC: cs42l43: Remove redundant semi-colon at end of function Charles Keepax
2024-08-01 10:04 ` Charles Keepax [this message]
2024-08-01 10:04 ` [PATCH v3 3/4] ASoC: cs35l45: Use new snd_soc_component_get_kcontrol() helper Charles Keepax
2024-08-01 16:38 ` Mark Brown
2024-08-02 8:44 ` Charles Keepax
2024-08-01 10:04 ` [PATCH v3 4/4] ASoC: cs42l43: Cache shutter IRQ control pointers Charles Keepax
2024-08-02 22:28 ` [PATCH v3 1/4] ASoC: cs42l43: Remove redundant semi-colon at end of function 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=20240801100413.1620481-2-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.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