Commit 93597fae authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-pcm: use dai_get_widget() at dpcm_get_be()

dpcm_get_be() has very duplicate code.

	dpcm_get_be() {
		...
		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
(1)			/* code for Playback */
		} else  {
(2)			/* code for Capture */
		}
	}

The difference between Playback (1) and Capture (2) code is pointer only
(= "playback_widget" or "caputre_widget").
OTOH, now we already has dai_get_widget() for it.
This means we can merge (1) and (2).
This patch do it and remove duplicated code.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/87ftf9bouq.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d9303690
...@@ -1246,47 +1246,30 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, ...@@ -1246,47 +1246,30 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
struct snd_soc_dapm_widget *widget, int stream) struct snd_soc_dapm_widget *widget, int stream)
{ {
struct snd_soc_pcm_runtime *be; struct snd_soc_pcm_runtime *be;
struct snd_soc_dapm_widget *w;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int i; int i;
dev_dbg(card->dev, "ASoC: find BE for widget %s\n", widget->name); dev_dbg(card->dev, "ASoC: find BE for widget %s\n", widget->name);
if (stream == SNDRV_PCM_STREAM_PLAYBACK) { for_each_card_rtds(card, be) {
for_each_card_rtds(card, be) {
if (!be->dai_link->no_pcm) if (!be->dai_link->no_pcm)
continue; continue;
dev_dbg(card->dev, "ASoC: try BE : %s\n", w = dai_get_widget(be->cpu_dai, stream);
be->cpu_dai->playback_widget ?
be->cpu_dai->playback_widget->name : "(not set)");
if (be->cpu_dai->playback_widget == widget) dev_dbg(card->dev, "ASoC: try BE : %s\n",
return be; w ? w->name : "(not set)");
for_each_rtd_codec_dai(be, i, dai) { if (w == widget)
if (dai->playback_widget == widget) return be;
return be;
}
}
} else {
for_each_card_rtds(card, be) {
if (!be->dai_link->no_pcm)
continue;
dev_dbg(card->dev, "ASoC: try BE %s\n", for_each_rtd_codec_dai(be, i, dai) {
be->cpu_dai->capture_widget ? w = dai_get_widget(dai, stream);
be->cpu_dai->capture_widget->name : "(not set)");
if (be->cpu_dai->capture_widget == widget) if (w == widget)
return be; return be;
for_each_rtd_codec_dai(be, i, dai) {
if (dai->capture_widget == widget)
return be;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment