ASoC: pcm: Reverse iterate DAIs when shutting them down
authorCezary Rojewski <cezary.rojewski@intel.com>
Fri, 26 Apr 2024 09:57:26 +0000 (11:57 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 29 Apr 2024 15:09:46 +0000 (00:09 +0900)
During startup snd_soc_dai_startup() is launched in ascending order and
the exact same thing is done during shutdown procedure. Reverse the
order in the latter so that it is symmetric to the former.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20240426095733.3946951-2-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/soc-pcm.c

index 2a1b6c198547c251cb427cc28c2228742769d3f7..8aa6ddb7ee1e8955af52a28ebfbfa93aabf9d17b 100644 (file)
@@ -1235,6 +1235,10 @@ struct snd_soc_pcm_runtime {
             ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \
                     ((dai) = (rtd)->dais[i]);                          \
             (i)++)
+#define for_each_rtd_dais_reverse(rtd, i, dai)                                 \
+       for ((i) = (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs - 1; \
+            (i) >= 0 && ((dai) = (rtd)->dais[i]);                              \
+            (i)--)
 #define for_each_rtd_ch_maps(rtd, i, ch_maps) for_each_link_ch_maps(rtd->dai_link, i, ch_maps)
 
 void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
index b0e1bd7f588ba7857a56fa905858333d333d83a0..711b2f49ed88de8df5db9a80dfdd82c112d5ced4 100644 (file)
@@ -724,7 +724,7 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd,
                }
        }
 
-       for_each_rtd_dais(rtd, i, dai)
+       for_each_rtd_dais_reverse(rtd, i, dai)
                snd_soc_dai_shutdown(dai, substream, rollback);
 
        snd_soc_link_shutdown(substream, rollback);