ASoC: soc-pcm: move soc_pcm_close() next to soc_pcm_open()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 10 Feb 2020 03:14:41 +0000 (12:14 +0900)
committerMark Brown <broonie@kernel.org>
Wed, 12 Feb 2020 23:52:07 +0000 (23:52 +0000)
This patch moves soc_pcm_close() next to soc_pcm_open().
This is prepare for soc_pcm_open() cleanup.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/8736bjcexx.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-pcm.c

index ae94d8a869924caea85b4b35250563929305de54..8aa775e0eb0dce639267ca33020e8633f7c3b8e9 100644 (file)
@@ -507,6 +507,50 @@ static int soc_pcm_components_close(struct snd_pcm_substream *substream)
        return ret;
 }
 
+/*
+ * Called by ALSA when a PCM substream is closed. Private data can be
+ * freed here. The cpu DAI, codec DAI, machine and components are also
+ * shutdown.
+ */
+static int soc_pcm_close(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_component *component;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       struct snd_soc_dai *codec_dai;
+       int i;
+
+       mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
+
+       snd_soc_runtime_deactivate(rtd, substream->stream);
+
+       snd_soc_dai_digital_mute(cpu_dai, 1, substream->stream);
+
+       snd_soc_dai_shutdown(cpu_dai, substream);
+
+       for_each_rtd_codec_dai(rtd, i, codec_dai)
+               snd_soc_dai_shutdown(codec_dai, substream);
+
+       soc_rtd_shutdown(rtd, substream);
+
+       soc_pcm_components_close(substream);
+
+       snd_soc_dapm_stream_stop(rtd, substream->stream);
+
+       mutex_unlock(&rtd->card->pcm_mutex);
+
+       for_each_rtd_components(rtd, i, component) {
+               pm_runtime_mark_last_busy(component->dev);
+               pm_runtime_put_autosuspend(component->dev);
+       }
+
+       for_each_rtd_components(rtd, i, component)
+               if (!component->active)
+                       pinctrl_pm_select_sleep_state(component->dev);
+
+       return 0;
+}
+
 /*
  * Called by ALSA when a PCM substream is opened, the runtime->hw record is
  * then initialized and any private data can be allocated. This also calls
@@ -663,50 +707,6 @@ static void codec2codec_close_delayed_work(struct snd_soc_pcm_runtime *rtd)
         */
 }
 
-/*
- * Called by ALSA when a PCM substream is closed. Private data can be
- * freed here. The cpu DAI, codec DAI, machine and components are also
- * shutdown.
- */
-static int soc_pcm_close(struct snd_pcm_substream *substream)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_component *component;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai;
-       int i;
-
-       mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass);
-
-       snd_soc_runtime_deactivate(rtd, substream->stream);
-
-       snd_soc_dai_digital_mute(cpu_dai, 1, substream->stream);
-
-       snd_soc_dai_shutdown(cpu_dai, substream);
-
-       for_each_rtd_codec_dai(rtd, i, codec_dai)
-               snd_soc_dai_shutdown(codec_dai, substream);
-
-       soc_rtd_shutdown(rtd, substream);
-
-       soc_pcm_components_close(substream);
-
-       snd_soc_dapm_stream_stop(rtd, substream->stream);
-
-       mutex_unlock(&rtd->card->pcm_mutex);
-
-       for_each_rtd_components(rtd, i, component) {
-               pm_runtime_mark_last_busy(component->dev);
-               pm_runtime_put_autosuspend(component->dev);
-       }
-
-       for_each_rtd_components(rtd, i, component)
-               if (!component->active)
-                       pinctrl_pm_select_sleep_state(component->dev);
-
-       return 0;
-}
-
 /*
  * Called by ALSA when the PCM substream is prepared, can set format, sample
  * rate, etc.  This function is non atomic and can be called multiple times,