All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 08/13] ASoC: soc-pcm: cleanup soc_pcm_apply_msb()
Date: 19 Feb 2020 15:56:36 +0900	[thread overview]
Message-ID: <87eeurjca6.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87pnebjcc4.wl-kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

soc_pcm_apply_msb() apply msb for CPU/Codec,
but, it has duplicate code. The difference is only
SNDRV_PCM_STREAM_PLAYBACK and SNDRV_PCM_STEAM_CAPTURE.

It is very verbose and duplicate code.
This patch simplify code by using snd_soc_dai_get_pcm_stream().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-pcm.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 8734ce051c51..4b9ade4349aa 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -363,29 +363,24 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
+	struct snd_soc_pcm_stream *pcm_codec, *pcm_cpu;
+	int stream = substream->stream;
 	int i;
 	unsigned int bits = 0, cpu_bits;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		for_each_rtd_codec_dai(rtd, i, codec_dai) {
-			if (codec_dai->driver->playback.sig_bits == 0) {
-				bits = 0;
-				break;
-			}
-			bits = max(codec_dai->driver->playback.sig_bits, bits);
-		}
-		cpu_bits = cpu_dai->driver->playback.sig_bits;
-	} else {
-		for_each_rtd_codec_dai(rtd, i, codec_dai) {
-			if (codec_dai->driver->capture.sig_bits == 0) {
-				bits = 0;
-				break;
-			}
-			bits = max(codec_dai->driver->capture.sig_bits, bits);
+	for_each_rtd_codec_dai(rtd, i, codec_dai) {
+		pcm_codec = snd_soc_dai_get_pcm_stream(codec_dai, stream);
+
+		if (pcm_codec->sig_bits == 0) {
+			bits = 0;
+			break;
 		}
-		cpu_bits = cpu_dai->driver->capture.sig_bits;
+		bits = max(pcm_codec->sig_bits, bits);
 	}
 
+	pcm_cpu = snd_soc_dai_get_pcm_stream(cpu_dai, stream);
+	cpu_bits = pcm_cpu->sig_bits;
+
 	soc_pcm_set_msb(substream, bits);
 	soc_pcm_set_msb(substream, cpu_bits);
 }
-- 
2.17.1


  parent reply	other threads:[~2020-02-19  7:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19  6:55 [PATCH 00/13] ASoC: soc-pcm cleanup step4 Kuninori Morimoto
2020-02-19  6:55 ` [PATCH 01/13] ASoC: soundwaire: qcom: use for_each_rtd_codec_dai() macro Kuninori Morimoto
2020-02-19  6:56 ` [PATCH 02/13] ASoC: qcom: sdm845: " Kuninori Morimoto
2020-02-19  6:56 ` [PATCH 03/13] ASoC: qcom: apq8016_sbc: " Kuninori Morimoto
2020-02-19  6:56 ` [PATCH 04/13] ASoC: intel: cml_rt1011_rt5682: " Kuninori Morimoto
2020-02-19  6:56 ` [PATCH 05/13] ASoC: intel: kbl_da7219_max98927: " Kuninori Morimoto
2020-02-19  6:56 ` [PATCH 06/13] ASoC: mediatek: mt8183-da7219-max98357: " Kuninori Morimoto
2020-02-19  6:56 ` [PATCH 07/13] ASoC: soc-pcm: add snd_soc_dai_get_pcm_stream() Kuninori Morimoto
2020-02-24 22:22   ` Applied "ASoC: soc-pcm: add snd_soc_dai_get_pcm_stream()" to the asoc tree Mark Brown
2020-02-19  6:56 ` Kuninori Morimoto [this message]
2020-02-24 22:21   ` Applied "ASoC: soc-pcm: cleanup soc_pcm_apply_msb()" " Mark Brown
2020-02-19  6:56 ` [PATCH 09/13] ASoC: soc-pcm: add snd_soc_dai_get_widget() Kuninori Morimoto
2020-02-24 22:21   ` Applied "ASoC: soc-pcm: add snd_soc_dai_get_widget()" to the asoc tree Mark Brown
2020-02-19  6:56 ` [PATCH 10/13] ASoC: soc-pcm: merge dpcm_run_new/old_update() into dpcm_fe_runtime_update() Kuninori Morimoto
2020-02-24 22:21   ` Applied "ASoC: soc-pcm: merge dpcm_run_new/old_update() into dpcm_fe_runtime_update()" to the asoc tree Mark Brown
2020-02-19  6:56 ` [PATCH 11/13] ASoC: soc-pcm: move dpcm_path_put() to soc-pcm.c Kuninori Morimoto
2020-02-24 22:21   ` Applied "ASoC: soc-pcm: move dpcm_path_put() to soc-pcm.c" to the asoc tree Mark Brown
2020-02-19  6:56 ` [PATCH 12/13] ASoC: soc-pcm: move CONFIG_DEBUG_FS functions to top side Kuninori Morimoto
2020-02-24 22:21   ` Applied "ASoC: soc-pcm: move CONFIG_DEBUG_FS functions to top side" to the asoc tree Mark Brown
2020-02-19  6:57 ` [PATCH 13/13] ASoC: soc-pcm: add dpcm_create/remove_debugfs_state() Kuninori Morimoto
2020-02-24 22:21   ` Applied "ASoC: soc-pcm: add dpcm_create/remove_debugfs_state()" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eeurjca6.wl-kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.