Commit c2cd8216 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

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

dpcm_end_walk_at_be() has very duplicate code.

	dpcm_end_walk_at_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/87eeutboul.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 93597fae
......@@ -1297,36 +1297,31 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget,
{
struct snd_soc_card *card = widget->dapm->card;
struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dapm_widget *w;
struct snd_soc_dai *dai;
int stream;
int i;
if (dir == SND_SOC_DAPM_DIR_OUT) {
for_each_card_rtds(card, rtd) {
if (!rtd->dai_link->no_pcm)
continue;
if (rtd->cpu_dai->playback_widget == widget)
return true;
/* adjust dir to stream */
if (dir == SND_SOC_DAPM_DIR_OUT)
stream = SNDRV_PCM_STREAM_PLAYBACK;
else
stream = SNDRV_PCM_STREAM_CAPTURE;
for_each_rtd_codec_dai(rtd, i, dai) {
if (dai->playback_widget == widget)
return true;
}
}
} else { /* SND_SOC_DAPM_DIR_IN */
for_each_card_rtds(card, rtd) {
if (!rtd->dai_link->no_pcm)
continue;
if (rtd->cpu_dai->capture_widget == widget)
w = dai_get_widget(rtd->cpu_dai, stream);
if (w == widget)
return true;
for_each_rtd_codec_dai(rtd, i, dai) {
if (dai->capture_widget == widget)
w = dai_get_widget(dai, stream);
if (w == widget)
return true;
}
}
}
return false;
}
......
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