diff mbox series

[5/5] ASoC: soc-pcm: unpack dpcm_set_fe_runtime()

Message ID 87mtvxvsgn.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Accepted
Commit 4fe28461e289e7209dc969d5878997069f5be157
Headers show
Series soc-pcm: tidyup snd_pcm_hardware setup for FE/BE | expand

Commit Message

Kuninori Morimoto Feb. 22, 2021, 12:47 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

dpcm_fe_dai_startup() (= A) calls dpcm_set_fe_runtime() (= B) to setup
DPCM runtime. From *naming point of view*, it sounds like setup function
for FE.

(A)	static int dpcm_fe_dai_startup(...)
	{
		...
(B)		dpcm_set_fe_runtime(...);
		...
	}

But in dpcm_set_fe_runtime() (= B),
It  setups FE by dpcm_runtime_setup_fe() (= X),
and setups BE by dpcm_runtime_merge_xxx() (= Y).

(B)	static void dpcm_set_fe_runtime(...)
	{
		...
(X)		dpcm_runtime_setup_fe(...);

 ^		dpcm_runtime_setup_be_format(...);
(Y)		dpcm_runtime_setup_be_chan(...);
 v		dpcm_runtime_setup_be_rate(...);
	}

These means that the function which is called as xxx_fe_xxx()
is setups both FE and BE. This is confusable and can be hot bed for bug.

Now dpcm_set_fe_runtime() (= B) is simple enough and confusable naming,
let's unpack it at dpcm_fe_dai_startup().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7fc7e3e24444..511c9218308a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1678,15 +1678,6 @@  static void dpcm_runtime_setup_be_rate(struct snd_pcm_substream *substream)
 	}
 }
 
-static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
-{
-	dpcm_runtime_setup_fe(substream);
-
-	dpcm_runtime_setup_be_format(substream);
-	dpcm_runtime_setup_be_chan(substream);
-	dpcm_runtime_setup_be_rate(substream);
-}
-
 static int dpcm_apply_symmetry(struct snd_pcm_substream *fe_substream,
 			       int stream)
 {
@@ -1766,7 +1757,11 @@  static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
 
 	fe->dpcm[stream].state = SND_SOC_DPCM_STATE_OPEN;
 
-	dpcm_set_fe_runtime(fe_substream);
+	dpcm_runtime_setup_fe(fe_substream);
+
+	dpcm_runtime_setup_be_format(fe_substream);
+	dpcm_runtime_setup_be_chan(fe_substream);
+	dpcm_runtime_setup_be_rate(fe_substream);
 
 	ret = dpcm_apply_symmetry(fe_substream, stream);
 	if (ret < 0)