Commit 846faaed authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-dai: add snd_soc_dai_hw_free()

Current ALSA SoC is directly using dai->driver->ops->xxx,
thus, it has deep nested bracket, and it makes code unreadable.
This patch adds new snd_soc_dai_hw_free() and use it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87y30qhn4w.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent aa6166c2
...@@ -148,6 +148,8 @@ int snd_soc_dai_is_dummy(struct snd_soc_dai *dai); ...@@ -148,6 +148,8 @@ int snd_soc_dai_is_dummy(struct snd_soc_dai *dai);
int snd_soc_dai_hw_params(struct snd_soc_dai *dai, int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
struct snd_pcm_substream *substream, struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params); struct snd_pcm_hw_params *params);
void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
struct snd_pcm_substream *substream);
struct snd_soc_dai_ops { struct snd_soc_dai_ops {
/* /*
......
...@@ -282,3 +282,10 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai, ...@@ -282,3 +282,10 @@ int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
return 0; return 0;
} }
void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
struct snd_pcm_substream *substream)
{
if (dai->driver->ops->hw_free)
dai->driver->ops->hw_free(substream, dai);
}
...@@ -3898,9 +3898,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, ...@@ -3898,9 +3898,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
snd_soc_dapm_widget_for_each_source_path(w, path) { snd_soc_dapm_widget_for_each_source_path(w, path) {
source = path->source->priv; source = path->source->priv;
if (source->driver->ops->hw_free) snd_soc_dai_hw_free(source, &substream);
source->driver->ops->hw_free(&substream,
source);
source->active--; source->active--;
if (source->driver->ops->shutdown) if (source->driver->ops->shutdown)
...@@ -3912,8 +3910,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, ...@@ -3912,8 +3910,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
snd_soc_dapm_widget_for_each_sink_path(w, path) { snd_soc_dapm_widget_for_each_sink_path(w, path) {
sink = path->sink->priv; sink = path->sink->priv;
if (sink->driver->ops->hw_free) snd_soc_dai_hw_free(sink, &substream);
sink->driver->ops->hw_free(&substream, sink);
sink->active--; sink->active--;
if (sink->driver->ops->shutdown) if (sink->driver->ops->shutdown)
......
...@@ -1011,8 +1011,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -1011,8 +1011,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
component_err: component_err:
soc_pcm_components_hw_free(substream, component); soc_pcm_components_hw_free(substream, component);
if (cpu_dai->driver->ops->hw_free) snd_soc_dai_hw_free(cpu_dai, substream);
cpu_dai->driver->ops->hw_free(substream, cpu_dai);
cpu_dai->rate = 0; cpu_dai->rate = 0;
interface_err: interface_err:
...@@ -1023,8 +1022,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -1023,8 +1022,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) if (!snd_soc_dai_stream_valid(codec_dai, substream->stream))
continue; continue;
if (codec_dai->driver->ops->hw_free) snd_soc_dai_hw_free(codec_dai, substream);
codec_dai->driver->ops->hw_free(substream, codec_dai);
codec_dai->rate = 0; codec_dai->rate = 0;
} }
...@@ -1083,12 +1081,10 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -1083,12 +1081,10 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) if (!snd_soc_dai_stream_valid(codec_dai, substream->stream))
continue; continue;
if (codec_dai->driver->ops->hw_free) snd_soc_dai_hw_free(codec_dai, substream);
codec_dai->driver->ops->hw_free(substream, codec_dai);
} }
if (cpu_dai->driver->ops->hw_free) snd_soc_dai_hw_free(cpu_dai, substream);
cpu_dai->driver->ops->hw_free(substream, cpu_dai);
mutex_unlock(&rtd->pcm_mutex); mutex_unlock(&rtd->pcm_mutex);
return 0; return 0;
......
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