alsa-devel.alsa-project.org archive mirror
 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 v2 10/11] ASoC: rsnd: tidyup rsnd_ssiu_busif_err_status_clear()
Date: 27 May 2021 11:41:56 +0900	[thread overview]
Message-ID: <87tumolwy3.wl-kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <878s40nbmc.wl-kuninori.morimoto.gx@renesas.com>


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

rsnd_ssiu_busif_err_status_clear() 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 | 45 +++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c
index 3a98ec2066bc..b79628761167 100644
--- a/sound/soc/sh/rcar/ssiu.c
+++ b/sound/soc/sh/rcar/ssiu.c
@@ -88,11 +88,9 @@ static void rsnd_ssiu_busif_err_irq_ctrl(struct rsnd_mod *mod, int enable)
 
 bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod)
 {
-	struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-	struct device *dev = rsnd_priv_to_dev(priv);
-	u32 status;
 	bool error = false;
 	int id = rsnd_mod_id(mod);
+	int shift, offset;
 	int i;
 
 	switch (id) {
@@ -101,31 +99,30 @@ bool rsnd_ssiu_busif_err_status_clear(struct rsnd_mod *mod)
 	case 2:
 	case 3:
 	case 4:
-		for (i = 0; i < 4; i++) {
-			status = rsnd_mod_read(mod, SSI_SYS_STATUS(i * 2));
-			status &= 0xf << (id * 4);
-
-			if (status) {
-				rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
-						      rsnd_mod_name(mod), status);
-				error = true;
-			}
-			rsnd_mod_write(mod, SSI_SYS_STATUS(i * 2), 0xf << (id * 4));
-		}
+		shift  = id;
+		offset = 0;
 		break;
 	case 9:
-		for (i = 0; i < 4; i++) {
-			status = rsnd_mod_read(mod, SSI_SYS_STATUS((i * 2) + 1));
-			status &= 0xf << 4;
+		shift  = 1;
+		offset = 1;
+		break;
+	}
 
-			if (status) {
-				rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
-						      rsnd_mod_name(mod), status);
-				error = true;
-			}
-			rsnd_mod_write(mod, SSI_SYS_STATUS((i * 2) + 1), 0xf << 4);
+	for (i = 0; i < 4; i++) {
+		u32 reg = SSI_SYS_STATUS(i * 2) + offset;
+		u32 status = rsnd_mod_read(mod, reg);
+		u32 val = 0xf << (shift * 4);
+
+		status &= val;
+		if (status) {
+			struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+			struct device *dev = rsnd_priv_to_dev(priv);
+
+			rsnd_print_irq_status(dev, "%s err status : 0x%08x\n",
+					      rsnd_mod_name(mod), status);
+			error = true;
 		}
-		break;
+		rsnd_mod_write(mod, reg, val);
 	}
 
 	return error;
-- 
2.25.1


  parent reply	other threads:[~2021-05-27  2:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27  2:39 [PATCH v2 00/11] ASoC: rsnd: tidyup and fixup rare MIXer issue Kuninori Morimoto
2021-05-27  2:40 ` [PATCH v2 01/11] ASoC: rsnd: call unregister for null_hw when removed Kuninori Morimoto
2021-05-27  2:40 ` [PATCH v2 02/11] ASoC: rsnd: ignore runtime NULL case at rsnd_runtime_channel_original_with_params() Kuninori Morimoto
2021-05-27  2:40 ` [PATCH v2 03/11] ASoC: rsnd: attach SSIU when SSI was DMA mode Kuninori Morimoto
2021-05-27  2:41 ` [PATCH v2 04/11] ASoC: rsnd: check BUIF error everytime Kuninori Morimoto
2021-05-27  2:41 ` [PATCH v2 05/11] ASoC: rsnd: indicate unknown error at rsnd_dai_call() Kuninori Morimoto
2021-05-27  2:41 ` [PATCH v2 06/11] ASoC: rsnd: incidate irq error message Kuninori Morimoto
2021-05-27  2:41 ` [PATCH v2 07/11] ASoC: rsnd: add debugfs support Kuninori Morimoto
2021-05-27  2:41 ` [PATCH v2 08/11] ASoC: rsnd: protect mod->status Kuninori Morimoto
2021-05-27  2:41 ` [PATCH v2 09/11] ASoC: rsnd: implement BUSIF related code in ssiu.c Kuninori Morimoto
2021-05-27  2:41 ` Kuninori Morimoto [this message]
2021-05-27  2:42 ` [PATCH v2 11/11] ASoC: rsnd: tidyup rsnd_ssiu_busif_err_irq_ctrl() Kuninori Morimoto
2021-05-28 16:04 ` [PATCH v2 00/11] 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=87tumolwy3.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).