ASoC: soc-pcm.c: remove indirect runtime copy
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 6 Mar 2023 01:43:54 +0000 (01:43 +0000)
committerMark Brown <broonie@kernel.org>
Tue, 14 Mar 2023 13:58:57 +0000 (13:58 +0000)
commit0d3a5178c2994eaf91ad135816a79138055b394a
treee2c9dfbc9c81845fde42eabdc9a80d391f00dea8
parent5c5a7521e9364a40fe2c1b67ab79991e3e9085df
ASoC: soc-pcm.c: remove indirect runtime copy

substream->runtime will be attached when substream was opened
at snd_pcm_attach_substream(). When it uses DPCM,
FE substream->runtime is attached, but BE substream->runtime is not.
Thus, we are copying FE substream->runtime to BE.

But, we are copyig FE substream->runtime to FE dpcm->runtime first (A),
and copy it to BE dpcm->runtime (B), and copy it to
BE substream->runtime (C).

static int dpcm_fe_dai_open(...) {
...
(A) fe->dpcm[stream].runtime = fe_substream->runtime;
...
}

static int dpcm_be_connect(...) {
...
(B) be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
...
}

int dpcm_be_dai_startup(...) {
...
(C) be_substream->runtime = be->dpcm[stream].runtime;
...
}

It is too roundabout and troublesome.
OTOH, it is directly copying fe_substream->runtime at dpcm_be_reparent()
without using be->dpcm[stream].runtime.

static void dpcm_be_reparent(...)
{
...
for_each_dpcm_fe(be, stream, dpcm) {
...
=> be_substream->runtime = fe_substream->runtime;
break;
}
}

This patch removes indirect copying.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87v8je64dh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-dpcm.h
sound/soc/soc-compress.c
sound/soc/soc-pcm.c