All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR
@ 2022-09-08 15:11 ` Judy Hsiao
  0 siblings, 0 replies; 8+ messages in thread
From: Judy Hsiao @ 2022-09-08 15:11 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: alsa-devel, linux-kernel, Brian Norris, Takashi Iwai,
	linux-rockchip, Mark Brown, Chen-Yu Tsai, Judy Hsiao,
	linux-arm-kernel

Use regmap_read_poll_timeout to poll I2S_CLR.
It also fixes the 'rockchip-i2s ff070000.i2s; fail to clear' and
return -EBUSY when the read of I2S_CLR exceeds the retry limit.

Fixes: 0ff9f8b9f592 ("ASoC: rockchip: i2s: Fix error code when fail
to read I2S_CLR")
Signed-off-by: Judy Hsiao <judyhsiao@chromium.org>
---
 sound/soc/rockchip/rockchip_i2s.c | 39 +++++++++++++------------------
 1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index f5f3540a9e18..02905eec615e 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -163,18 +163,14 @@ static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
 						 I2S_CLR_TXC | I2S_CLR_RXC);
 			if (ret < 0)
 				goto end;
-			regmap_read(i2s->regmap, I2S_CLR, &val);
-
-			/* Should wait for clear operation to finish */
-			while (val) {
-				regmap_read(i2s->regmap, I2S_CLR, &val);
-				retry--;
-				if (!retry) {
-					dev_warn(i2s->dev, "fail to clear\n");
-					ret = -EBUSY;
-					break;
-				}
-			}
+			ret = regmap_read_poll_timeout(i2s->regmap,
+						       I2S_CLR,
+						       val,
+						       val != 0,
+						       20,
+						       200);
+			if (ret < 0)
+				dev_warn(i2s->dev, "fail to clear\n");
 		}
 	}
 end:
@@ -226,17 +222,14 @@ static int rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
 						 I2S_CLR_TXC | I2S_CLR_RXC);
 			if (ret < 0)
 				goto end;
-			regmap_read(i2s->regmap, I2S_CLR, &val);
-			/* Should wait for clear operation to finish */
-			while (val) {
-				regmap_read(i2s->regmap, I2S_CLR, &val);
-				retry--;
-				if (!retry) {
-					dev_warn(i2s->dev, "fail to clear\n");
-					ret = -EBUSY;
-					break;
-				}
-			}
+			ret = regmap_read_poll_timeout(i2s->regmap,
+						       I2S_CLR,
+						       val,
+						       val != 0,
+						       20,
+						       200);
+			if (ret < 0)
+				dev_warn(i2s->dev, "fail to clear\n");
 		}
 	}
 end:
-- 
2.37.2.789.g6183377224-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-09-14  0:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-08 15:11 [PATCH v1] ASoC: rockchip: i2s: use regmap_read_poll_timeout to poll I2S_CLR Judy Hsiao
2022-09-08 15:11 ` Judy Hsiao
2022-09-08 15:11 ` Judy Hsiao
2022-09-08 15:11 ` Judy Hsiao
2022-09-14  0:44 ` Brian Norris
2022-09-14  0:44   ` Brian Norris
2022-09-14  0:44   ` Brian Norris
2022-09-14  0:44   ` Brian Norris

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.