From: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx> Current snd_soc_runtime_action() is counting dai->stream_active for Playback/Capture, dai->active for DAI static void snd_soc_runtime_action(...) { ... for_each_rtd_dais(rtd, i, dai) { dai->stream_active[stream] += action; dai->active += action; ... } } But, these are very verbose, because we can calculate DAI activity from stream_activity. This patch adds snd_soc_dai_activity() which calculate DAI activity from DAI stream_activity. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx> --- include/sound/soc-dai.h | 2 +- sound/soc/soc-dai.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 2a0a5af1c1ae..887575d59e31 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -137,7 +137,7 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); /* Digital Audio Interface mute */ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, int direction); - +int snd_soc_dai_activity(struct snd_soc_dai *dai); int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai, unsigned int *tx_num, unsigned int *tx_slot, diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 8e5fe012aa1d..aa0826136f57 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -305,6 +305,18 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, } EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); +int snd_soc_dai_activity(struct snd_soc_dai *dai) +{ + int stream, active; + + active = 0; + for_each_pcm_streams(stream) + active += dai->stream_active[stream]; + + return active; +} +EXPORT_SYMBOL_GPL(snd_soc_dai_activity); + int snd_soc_dai_hw_params(struct snd_soc_dai *dai, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) -- 2.17.1