diff mbox series

[v2,2/3] spi: sh-msiof: Use readl_poll_timeout_atomic() instead of open-coding

Message ID 20190402144023.27422-3-geert+renesas@glider.be (mailing list archive)
State Accepted
Commit 9115b4d89b213dc73fd35844e0199b1763f751d6
Headers show
Series spi: sh-msiof: Add reset of registers before starting transfer | expand

Commit Message

Geert Uytterhoeven April 2, 2019, 2:40 p.m. UTC
Replace the open-coded loop in sh_msiof_modify_ctr_wait() by a call to
the readl_poll_timeout_atomic() helper macro.

Suggested-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v2:
  - New.
---
 drivers/spi/spi-sh-msiof.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Wolfram Sang April 2, 2019, 2:51 p.m. UTC | #1
On Tue, Apr 02, 2019 at 04:40:22PM +0200, Geert Uytterhoeven wrote:
> Replace the open-coded loop in sh_msiof_modify_ctr_wait() by a call to
> the readl_poll_timeout_atomic() helper macro.
> 
> Suggested-by: Wolfram Sang <wsa@the-dreams.de>

Please use me Renesas related address. Like in this new tag:

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Wolfram Sang April 3, 2019, 6:54 a.m. UTC | #2
Mark,

> Suggested-by: Wolfram Sang <wsa@the-dreams.de>

Any chance this email address can be changed to the one I used for my
Rev-by two lines below? Nothing major, but would be nice.

> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks,

   Wolfram
Mark Brown April 3, 2019, 8:06 a.m. UTC | #3
On Wed, Apr 03, 2019 at 08:54:06AM +0200, Wolfram Sang wrote:

> Any chance this email address can be changed to the one I used for my
> Rev-by two lines below? Nothing major, but would be nice.

> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Required rebasing but it's only been published briefly so OK...
diff mbox series

Patch

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 6edc76636e81a801..3243ff258896595b 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -18,6 +18,7 @@ 
 #include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -219,21 +220,14 @@  static int sh_msiof_modify_ctr_wait(struct sh_msiof_spi_priv *p,
 {
 	u32 mask = clr | set;
 	u32 data;
-	int k;
 
 	data = sh_msiof_read(p, CTR);
 	data &= ~clr;
 	data |= set;
 	sh_msiof_write(p, CTR, data);
 
-	for (k = 100; k > 0; k--) {
-		if ((sh_msiof_read(p, CTR) & mask) == set)
-			break;
-
-		udelay(10);
-	}
-
-	return k > 0 ? 0 : -ETIMEDOUT;
+	return readl_poll_timeout_atomic(p->mapbase + CTR, data,
+					 (data & mask) == set, 10, 1000);
 }
 
 static irqreturn_t sh_msiof_spi_irq(int irq, void *data)