diff mbox series

[v2,02/21] ASoC: soc-dai: add snd_soc_dai_action()

Message ID 878shu9ajj.wl-kuninori.morimoto.gx@renesas.com
State Accepted
Commit dc82910682ef06d5e5a81b4b359945b6f669ee3b
Headers show
Series ASoC: cleanup DAI/Component activity | expand

Commit Message

Kuninori Morimoto May 14, 2020, 8:37 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_soc_runtime_action() updates DAI's xxx_acitve.
We should update these in the same time, and
it can be implemented at soc-dai.c.
This patch adds snd_soc_dai_action() for it.
This is prepare for xxx_active cleanup.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2
	- new patch

 include/sound/soc-dai.h | 4 ++++
 sound/soc/soc-dai.c     | 9 +++++++++
 sound/soc/soc-pcm.c     | 7 ++-----
 3 files changed, 15 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 2a0a5af1c1ae..019c222a0b0d 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -161,6 +161,10 @@  void snd_soc_dai_resume(struct snd_soc_dai *dai);
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 			     struct snd_soc_pcm_runtime *rtd, int num);
 bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
+void snd_soc_dai_action(struct snd_soc_dai *dai,
+			int stream, int action);
+#define snd_soc_dai_activate(dai, stream)   snd_soc_dai_action(dai, stream,  1)
+#define snd_soc_dai_deactivate(dai, stream) snd_soc_dai_action(dai, stream, -1)
 
 int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order);
 int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 8e5fe012aa1d..3208f244c1b8 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -388,6 +388,15 @@  bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
 	return stream->channels_min;
 }
 
+void snd_soc_dai_action(struct snd_soc_dai *dai,
+			int stream, int action)
+{
+	dai->stream_active[stream]	+= action;
+	dai->active			+= action;
+	dai->component->active		+= action;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_action);
+
 int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order)
 {
 	struct snd_soc_dai *dai;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index e7175afd9a73..8d414f0ae2f9 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -276,11 +276,8 @@  void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
 
 	lockdep_assert_held(&rtd->card->pcm_mutex);
 
-	for_each_rtd_dais(rtd, i, dai) {
-		dai->stream_active[stream] += action;
-		dai->active += action;
-		dai->component->active += action;
-	}
+	for_each_rtd_dais(rtd, i, dai)
+		snd_soc_dai_action(dai, stream, action);
 }
 EXPORT_SYMBOL_GPL(snd_soc_runtime_action);