mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andy@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH v1 5/7] auxdisplay: arm-charlcd: Use readl_poll_timeout
Date: Mon, 29 Dec 2025 14:52:38 +0100	[thread overview]
Message-ID: <20251229142349.1251843-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20251229142349.1251843-1-andriy.shevchenko@linux.intel.com>

Use readl_poll_timeout_atomic() from <iopoll.h> instead of using
custom poll loops.

The timeout settings are different, but that shouldn't be much of a
problem. Instead of polling 10 times in a close loop, it polls for
one millisecond.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/auxdisplay/arm-charlcd.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/auxdisplay/arm-charlcd.c b/drivers/auxdisplay/arm-charlcd.c
index ac8604d3b9a0..a537126f5d6a 100644
--- a/drivers/auxdisplay/arm-charlcd.c
+++ b/drivers/auxdisplay/arm-charlcd.c
@@ -13,7 +13,7 @@
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
@@ -115,20 +115,14 @@ static u8 charlcd_4bit_read_char(struct charlcd *lcd)
 {
 	u8 data;
 	u32 val;
-	int i;
 
 	/* If we can, use an IRQ to wait for the data, else poll */
 	if (lcd->irq >= 0)
 		charlcd_wait_complete_irq(lcd);
 	else {
-		i = 0;
-		val = 0;
-		while (!(val & CHAR_RAW_VALID) && i < 10) {
-			udelay(100);
-			val = readl(lcd->virtbase + CHAR_RAW);
-			i++;
-		}
-
+		udelay(100);
+		readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val,
+					  val & CHAR_RAW_VALID, 100, 1000);
 		writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
 	}
 	msleep(1);
@@ -140,13 +134,9 @@ static u8 charlcd_4bit_read_char(struct charlcd *lcd)
 	 * The second read for the low bits does not trigger an IRQ
 	 * so in this case we have to poll for the 4 lower bits
 	 */
-	i = 0;
-	val = 0;
-	while (!(val & CHAR_RAW_VALID) && i < 10) {
-		udelay(100);
-		val = readl(lcd->virtbase + CHAR_RAW);
-		i++;
-	}
+	udelay(100);
+	readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val,
+				  val & CHAR_RAW_VALID, 100, 1000);
 	writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
 	msleep(1);
 
-- 
2.50.1


  parent reply	other threads:[~2025-12-29 14:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-29 13:52 [PATCH v1 0/7] auxdisplay: arm-charlcd: refactor with modern APIs Andy Shevchenko
2025-12-29 13:52 ` [PATCH v1 1/7] auxdisplay: arm-charlcd: convert to use device managed APIs Andy Shevchenko
2025-12-29 13:52 ` [PATCH v1 2/7] auxdisplay: arm-charlcd: Remove unneeded info message Andy Shevchenko
2025-12-29 13:52 ` [PATCH v1 3/7] auxdisplay: arm-charlcd: drop of_match_ptr() Andy Shevchenko
2025-12-29 13:52 ` [PATCH v1 4/7] auxdisplay: arm-charlcd: Don't use "proxy" headers Andy Shevchenko
2025-12-29 13:52 ` Andy Shevchenko [this message]
2025-12-29 13:52 ` [PATCH v1 6/7] auxdisplay: arm-charlcd: Join string literals back Andy Shevchenko
2025-12-29 13:52 ` [PATCH v1 7/7] auxdisplay: arm-charlcd: Remove redundant ternary operators Andy Shevchenko
2026-01-07 21:06 ` [PATCH v1 0/7] auxdisplay: arm-charlcd: refactor with modern APIs Andy Shevchenko
2026-01-07 21:08   ` Andy Shevchenko
2026-01-09 11:30     ` Andy Shevchenko
2026-01-09 14:29     ` Linus Walleij
2026-01-09 16:15       ` Andy Shevchenko

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=20251229142349.1251843-6-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®