Skip to content

Commit 84373fa

Browse files
committed
ASoC: add snd_soc_lookup_component_by_name helper
Add a helper to help user to get the component by name. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent fedfcf1 commit 84373fa

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

include/sound/soc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ struct snd_soc_component *snd_soc_lookup_component_nolocked(struct device *dev,
465465
const char *driver_name);
466466
struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
467467
const char *driver_name);
468+
struct snd_soc_component *snd_soc_lookup_component_by_name(const char *component_name);
468469

469470
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd);
470471
#ifdef CONFIG_SND_SOC_COMPRESS

sound/soc/soc-core.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,19 @@ struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
404404
}
405405
EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
406406

407+
struct snd_soc_component *snd_soc_lookup_component_by_name(const char *component_name)
408+
{
409+
struct snd_soc_component *component;
410+
411+
guard(mutex)(&client_mutex);
412+
for_each_component(component)
413+
if (strstr(component->name, component_name))
414+
return component;
415+
416+
return NULL;
417+
}
418+
EXPORT_SYMBOL_GPL(snd_soc_lookup_component_by_name);
419+
407420
struct snd_soc_pcm_runtime
408421
*snd_soc_get_pcm_runtime(struct snd_soc_card *card,
409422
struct snd_soc_dai_link *dai_link)

0 commit comments

Comments
 (0)