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 10/10] ASoC: rsnd: tidyup rsnd_ssiu_busif_err_irq_ctrl()
Date: 25 May 2021 09:03:46 +0900	[thread overview]
Message-ID: <878s43of19.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87mtsjof3w.wl-kuninori.morimoto.gx@renesas.com>


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

rsnd_ssiu_busif_err_irq_ctrl() has very similar duplicated code.
This patch merge and tidyup the code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/sh/rcar/ssiu.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c
index b79628761167..4363508e8250 100644
--- a/sound/soc/sh/rcar/ssiu.c
+++ b/sound/soc/sh/rcar/ssiu.c
@@ -50,8 +50,8 @@ static const int gen3_id[] = { 0, 8, 16, 24, 32, 40, 41, 42, 43, 44 };
 #define rsnd_ssiu_busif_err_irq_disable(mod) rsnd_ssiu_busif_err_irq_ctrl(mod, 0)
 static void rsnd_ssiu_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable)
 {
-	u32 sys_int_enable = 0;
 	int id = rsnd_mod_id(mod);
+	int shift, offset;
 	int i;
 
 	switch (id) {
@@ -60,30 +60,26 @@ static void rsnd_ssiu_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable)
 	case 2:
 	case 3:
 	case 4:
-		for (i = 0; i < 4; i++) {
-			sys_int_enable = rsnd_mod_read(mod, SSI_SYS_INT_ENABLE(i * 2));
-			if (enable)
-				sys_int_enable |= 0xf << (id * 4);
-			else
-				sys_int_enable &= ~(0xf << (id * 4));
-			rsnd_mod_write(mod,
-				       SSI_SYS_INT_ENABLE(i * 2),
-				       sys_int_enable);
-		}
+		shift  = id;
+		offset = 0;
 		break;
 	case 9:
-		for (i = 0; i < 4; i++) {
-			sys_int_enable = rsnd_mod_read(mod, SSI_SYS_INT_ENABLE((i * 2) + 1));
-			if (enable)
-				sys_int_enable |= 0xf << 4;
-			else
-				sys_int_enable &= ~(0xf << 4);
-			rsnd_mod_write(mod,
-				       SSI_SYS_INT_ENABLE((i * 2) + 1),
-				       sys_int_enable);
-		}
+		shift  = 1;
+		offset = 1;
 		break;
 	}
+
+	for (i = 0; i < 4; i++) {
+		enum rsnd_reg reg = SSI_SYS_INT_ENABLE((i * 2) + offset);
+		u32 val = 0xf << (shift * 4);
+		u32 sys_int_enable = rsnd_mod_read(mod, reg);
+
+		if (enable)
+			sys_int_enable |= val;
+		else
+			sys_int_enable &= ~val;
+		rsnd_mod_write(mod, reg, sys_int_enable);
+	}
 }
 
 bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod)
-- 
2.25.1


  parent reply	other threads:[~2021-05-25  0:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  0:02 [PATCH 00/10] ASoC: rsnd: tidyup and fixup rare MIXer issue Kuninori Morimoto
2021-05-25  0:02 ` [PATCH 01/10] ASoC: rsnd: ignore runtime NULL case at rsnd_runtime_channel_original_with_params() Kuninori Morimoto
2021-05-25  0:02 ` [PATCH 02/10] ASoC: rsnd: attach SSIU when SSI was DMA mode Kuninori Morimoto
2021-05-25  0:02 ` [PATCH 03/10] ASoC: rsnd: check BUIF error everytime Kuninori Morimoto
2021-05-25  0:03 ` [PATCH 04/10] ASoC: rsnd: indicate unknown error at rsnd_dai_call() Kuninori Morimoto
2021-05-25  0:03 ` [PATCH 05/10] ASoC: rsnd: incidate irq error message Kuninori Morimoto
2021-05-25  0:03 ` [PATCH 06/10] ASoC: rsnd: add debugfs support Kuninori Morimoto
2021-05-26  1:59   ` Kuninori Morimoto
2021-05-25  0:03 ` [PATCH 07/10] ASoC: rsnd: protect mod->status Kuninori Morimoto
2021-05-25  0:03 ` [PATCH 08/10] ASoC: rsnd: implement BUSIF related code in ssiu.c Kuninori Morimoto
2021-05-25  0:03 ` [PATCH 09/10] ASoC: rsnd: tidyup rsnd_ssiu_busif_err_status_clear() Kuninori Morimoto
2021-05-25  0:03 ` Kuninori Morimoto [this message]
2021-05-28 16:04 ` [PATCH 00/10] ASoC: rsnd: tidyup and fixup rare MIXer issue 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=878s43of19.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.