Commit 8cce6569 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mark Brown

ASoC: (cosmetic) simplify dpcm_prune_paths()

Currently dpcm_prune_paths() has up to 4 nested condition and loop
levels, which forces the code to use flags for flow control.
Extracting widget status verification code from dpcm_prune_paths()
into a separate function simplifies the code.
Signed-off-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Link: https://lore.kernel.org/r/20200312095214.15126-2-guennadi.liakhovetski@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4d90a4e6
...@@ -1626,45 +1626,46 @@ void dpcm_path_put(struct snd_soc_dapm_widget_list **list) ...@@ -1626,45 +1626,46 @@ void dpcm_path_put(struct snd_soc_dapm_widget_list **list)
snd_soc_dapm_dai_free_widgets(list); snd_soc_dapm_dai_free_widgets(list);
} }
static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, static bool dpcm_be_is_active(struct snd_soc_dpcm *dpcm, int stream,
struct snd_soc_dapm_widget_list **list_) struct snd_soc_dapm_widget_list *list)
{ {
struct snd_soc_dpcm *dpcm;
struct snd_soc_dapm_widget_list *list = *list_;
struct snd_soc_dapm_widget *widget; struct snd_soc_dapm_widget *widget;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int prune = 0; unsigned int i;
int do_prune;
/* Destroy any old FE <--> BE connections */ /* is there a valid CPU DAI widget for this BE */
for_each_dpcm_be(fe, stream, dpcm) { for_each_rtd_cpu_dais(dpcm->be, i, dai) {
unsigned int i; widget = snd_soc_dai_get_widget(dai, stream);
/* is there a valid CPU DAI widget for this BE */ /*
do_prune = 1; * The BE is pruned only if none of the cpu_dai
for_each_rtd_cpu_dais(dpcm->be, i, dai) { * widgets are in the active list.
widget = snd_soc_dai_get_widget(dai, stream); */
if (widget && widget_in_list(list, widget))
return true;
}
/* /* is there a valid CODEC DAI widget for this BE */
* The BE is pruned only if none of the cpu_dai for_each_rtd_codec_dais(dpcm->be, i, dai) {
* widgets are in the active list. widget = snd_soc_dai_get_widget(dai, stream);
*/
if (widget && widget_in_list(list, widget))
do_prune = 0;
}
if (!do_prune)
continue;
/* is there a valid CODEC DAI widget for this BE */ /* prune the BE if it's no longer in our active list */
do_prune = 1; if (widget && widget_in_list(list, widget))
for_each_rtd_codec_dais(dpcm->be, i, dai) { return true;
widget = snd_soc_dai_get_widget(dai, stream); }
/* prune the BE if it's no longer in our active list */ return false;
if (widget && widget_in_list(list, widget)) }
do_prune = 0;
} static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
if (!do_prune) struct snd_soc_dapm_widget_list **list_)
{
struct snd_soc_dpcm *dpcm;
int prune = 0;
/* Destroy any old FE <--> BE connections */
for_each_dpcm_be(fe, stream, dpcm) {
if (dpcm_be_is_active(dpcm, stream, *list_))
continue; continue;
dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n",
......
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