]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: add snd_soc_lookup_component_by_name helper
authorBard Liao <yung-chuan.liao@linux.intel.com>
Wed, 25 Feb 2026 13:50:02 +0000 (21:50 +0800)
committerMark Brown <broonie@kernel.org>
Sun, 1 Mar 2026 23:48:52 +0000 (23:48 +0000)
Add a helper to help user to get the component by name.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20260225135004.2322987-2-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/soc-core.c

index 7d8376c8e1bededf7f5a3cb478b6f1f966c99da5..1a486153dc76d3f76e1dd81635d9718f677a1eb9 100644 (file)
@@ -465,6 +465,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
index d0fffef65daf5ee79fb54bd83b51a84347032a18..f41ca5109a6a10dbfc2f36ac100b6edb4e9f4e74 100644 (file)
@@ -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)