[SRU][R][PATCH 5/7] ASoC: add snd_soc_lookup_component_by_name helper
Chris Chiu
chris.chiu at canonical.com
Tue Mar 17 03:44:36 UTC 2026
From: Bard Liao <yung-chuan.liao at linux.intel.com>
BugLink: https://bugs.launchpad.net/bugs/2143902
Add a helper to help user to get the component by name.
Signed-off-by: Bard Liao <yung-chuan.liao at linux.intel.com>
Reviewed-by: Charles Keepax <ckeepax at opensource.cirrus.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi at linux.intel.com>
Link: https://patch.msgid.link/20260225135004.2322987-2-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie at kernel.org>
(cherry picked from commit 98eb42c7de6b0185c914df4cca61b49ff76821ee linux-next)
Signed-off-by: Chris Chiu <chris.chiu at canonical.com>
---
include/sound/soc.h | 1 +
sound/soc/soc-core.c | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 1fffef311c41..89ada3fcd5ae 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -451,6 +451,7 @@ struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
const char *driver_name);
struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
const char *driver_name);
+struct snd_soc_component *snd_soc_lookup_component_by_name(const char *component_name);
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd);
#ifdef CONFIG_SND_SOC_COMPRESS
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index cc9125ffe92a..95dbcd8c8967 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -404,6 +404,19 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
}
EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
+struct snd_soc_component *snd_soc_lookup_component_by_name(const char *component_name)
+{
+ struct snd_soc_component *component;
+
+ guard(mutex)(&client_mutex);
+ for_each_component(component)
+ if (strstr(component->name, component_name))
+ return component;
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_lookup_component_by_name);
+
struct snd_soc_pcm_runtime
*snd_soc_get_pcm_runtime(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_link)
--
2.43.0
More information about the kernel-team
mailing list