ASoC: soc-pcm: add dpcm_fe_dai_cleanup()
dpcm_fe_dai_close() and error case of dpcm_fe_dai_open() need to do same cleanup operation. To avoid duplicate code, this patch adds dpcm_fe_dai_cleanup() and use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Link: https://lore.kernel.org/r/87o8tap9uq.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
30fca26f8e
Коммит
265694b67c
|
@ -2978,14 +2978,11 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
|
static void dpcm_fe_dai_cleanup(struct snd_pcm_substream *fe_substream)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
|
struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
|
||||||
struct snd_soc_dpcm *dpcm;
|
struct snd_soc_dpcm *dpcm;
|
||||||
int stream = fe_substream->stream, ret;
|
int stream = fe_substream->stream;
|
||||||
|
|
||||||
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
|
|
||||||
ret = dpcm_fe_dai_shutdown(fe_substream);
|
|
||||||
|
|
||||||
/* mark FE's links ready to prune */
|
/* mark FE's links ready to prune */
|
||||||
for_each_dpcm_be(fe, stream, dpcm)
|
for_each_dpcm_be(fe, stream, dpcm)
|
||||||
|
@ -2994,6 +2991,18 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
|
||||||
dpcm_be_disconnect(fe, stream);
|
dpcm_be_disconnect(fe, stream);
|
||||||
|
|
||||||
fe->dpcm[stream].runtime = NULL;
|
fe->dpcm[stream].runtime = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
|
||||||
|
{
|
||||||
|
struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
|
||||||
|
ret = dpcm_fe_dai_shutdown(fe_substream);
|
||||||
|
|
||||||
|
dpcm_fe_dai_cleanup(fe_substream);
|
||||||
|
|
||||||
mutex_unlock(&fe->card->mutex);
|
mutex_unlock(&fe->card->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3001,7 +3010,6 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream)
|
||||||
static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
|
static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
|
||||||
{
|
{
|
||||||
struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
|
struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
|
||||||
struct snd_soc_dpcm *dpcm;
|
|
||||||
struct snd_soc_dapm_widget_list *list;
|
struct snd_soc_dapm_widget_list *list;
|
||||||
int ret;
|
int ret;
|
||||||
int stream = fe_substream->stream;
|
int stream = fe_substream->stream;
|
||||||
|
@ -3021,14 +3029,8 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
|
||||||
dpcm_process_paths(fe, stream, &list, 1);
|
dpcm_process_paths(fe, stream, &list, 1);
|
||||||
|
|
||||||
ret = dpcm_fe_dai_startup(fe_substream);
|
ret = dpcm_fe_dai_startup(fe_substream);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
/* clean up all links */
|
dpcm_fe_dai_cleanup(fe_substream);
|
||||||
for_each_dpcm_be(fe, stream, dpcm)
|
|
||||||
dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
|
|
||||||
|
|
||||||
dpcm_be_disconnect(fe, stream);
|
|
||||||
fe->dpcm[stream].runtime = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dpcm_clear_pending_state(fe, stream);
|
dpcm_clear_pending_state(fe, stream);
|
||||||
dpcm_path_put(&list);
|
dpcm_path_put(&list);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче