ASoC: Add helper to find codec_dai from dai_name
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Thu, 12 Oct 2017 23:38:02 +0000 (18:38 -0500)
committerMark Brown <broonie@kernel.org>
Wed, 18 Oct 2017 11:26:28 +0000 (12:26 +0100)
Create a helper function to remove duplicate code used in machine drivers

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h

index d22de9712c451d67a9ee068ab8001589f55901bd..deacbafbae1709f400ffb1e47d7a3834d8b82614 100644 (file)
@@ -1720,6 +1720,20 @@ struct snd_soc_dai *snd_soc_find_dai(
 
 #include <sound/soc-dai.h>
 
+static inline
+struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
+                                              const char *dai_name)
+{
+       struct snd_soc_pcm_runtime *rtd;
+
+       list_for_each_entry(rtd, &card->rtd_list, list) {
+               if (!strcmp(rtd->codec_dai->name, dai_name))
+                       return rtd->codec_dai;
+       }
+
+       return NULL;
+}
+
 #ifdef CONFIG_DEBUG_FS
 extern struct dentry *snd_soc_debugfs_root;
 #endif