From: Pierre-Louis Bossart Date: Thu, 12 Oct 2017 23:38:02 +0000 (-0500) Subject: ASoC: Add helper to find codec_dai from dai_name X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7c761b593e2c1dc6bc6c0c15ec338af1f00cabd7;p=linux.git ASoC: Add helper to find codec_dai from dai_name Create a helper function to remove duplicate code used in machine drivers Suggested-by: Takashi Iwai Signed-off-by: Pierre-Louis Bossart Acked-by: Liam Girdwood Reviewed-by: Andy Shevchenko Signed-off-by: Mark Brown --- diff --git a/include/sound/soc.h b/include/sound/soc.h index d22de9712c451..deacbafbae170 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1720,6 +1720,20 @@ struct snd_soc_dai *snd_soc_find_dai( #include +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