[PATCH] ASoC: soc-pcm: Revert "call snd_soc_component_open/close() once"
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Wed Feb 26 01:55:47 CET 2020
Hi Kai, again
Cc Mark
Maybe this is too late, but I want to tell
the reason why I wanted to add flag on each component.
> > 1. do the cleanup locally in soc_pcm_components_open()
> > [PATCH] ASoC: soc-pcm: fix state tracking error in snd_soc_component_open/close()
> >
> > 2. revert to original implementation with "last" passed to components_open()
> > [PATCH] ASoC: soc-pcm: Revert "call snd_soc_component_open/close() once"
> >
> > 3. implement opened/module counters
> > [PATCH][RFC] ASoC: soc-component: count snd_soc_component_open/close()
I can see this kind of implementation at many place.
For example, soc_pcm_open() has error handling.
But, it is same as soc_pcm_close(), but it can't call it directly,
because it needs to care about "successed until where" for now.
If each component / rtd / dai have "done" flag or count,
soc_pcm_open() can call soc_pcm_close() directly
without thinking about "until", because each flag can handle/indicate it.
The good point is we can reduce duplicate implementation.
And it can avoid future bug. Because today, we need to care both
soc_pcm_close() and error handling in soc_pcm_open(), it is not good for me.
static int soc_pcm_open(struct snd_pcm_substream *substream)
{
...
return 0;
/*
* From here, "implementation" is same as soc_pcm_close()
*/
config_err:
for_each_rtd_dais(rtd, i, dai)
snd_soc_dai_shutdown(dai, substream);
soc_rtd_shutdown(rtd, substream);
rtd_startup_err:
soc_pcm_components_close(substream, NULL);
component_err:
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 ret;
}
Thank you for your help !!
Best regards
---
Kuninori Morimoto
More information about the Alsa-devel
mailing list