mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] include: linux/iopoll.h: add optional PBL support
@ 2025-01-08 11:04 Ahmad Fatoum
  2025-01-08 11:04 ` [PATCH 2/2] mci: imx-esdhc: implement esdhc_poll using sdhci_read32_poll_timeout Ahmad Fatoum
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2025-01-08 11:04 UTC (permalink / raw)
  To: barebox; +Cc: ske, Ahmad Fatoum

While we don't have generic clocksource support in PBL, there is no
reason to not enable read_poll_timeout for use on platforms that have
their own get_time_ns.

Allow these platforms to use read_poll_timeout by defining two macros:
read_pol_is_timeout and read_poll_get_time_ns().

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/linux/iopoll.h | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index 9350a3d05007..36a2541eb4ce 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -12,6 +12,18 @@
 #include <clock.h>
 #include <pbl.h>
 
+#if IN_PROPER
+# define read_poll_get_time_ns()	get_time_ns()
+# define read_poll_is_timeout(s, t)	is_timeout(s, t)
+#else
+# ifndef read_poll_get_time_ns
+#  define read_poll_get_time_ns()	0
+# endif
+# ifndef read_poll_is_timeout
+#  define read_poll_is_timeout(s, t)	((void)s, (void)t, 0)
+# endif
+#endif
+
 /**
  * read_poll_timeout - Periodically poll an address until a condition is met or a timeout occurs
  * @op: accessor function (takes @addr as its only argument)
@@ -31,15 +43,13 @@
  */
 #define read_poll_timeout(op, val, cond, timeout_us, args...)	\
 ({ \
-	uint64_t start = 0; \
-	if (IN_PROPER && (timeout_us) != 0) \
-		start = get_time_ns(); \
+	uint64_t start = timeout_us ? read_poll_get_time_ns() : 0; \
 	for (;;) { \
 		(val) = op(args); \
 		if (cond) \
 			break; \
-		if (IN_PROPER && (timeout_us) != 0 && \
-		    is_timeout(start, ((timeout_us) * USECOND))) { \
+		if ((timeout_us) != 0 && \
+		    read_poll_is_timeout(start, ((timeout_us) * USECOND))) { \
 			(val) = op(args); \
 			break; \
 		} \
-- 
2.39.5




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

end of thread, other threads:[~2025-01-08 15:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-08 11:04 [PATCH 1/2] include: linux/iopoll.h: add optional PBL support Ahmad Fatoum
2025-01-08 11:04 ` [PATCH 2/2] mci: imx-esdhc: implement esdhc_poll using sdhci_read32_poll_timeout Ahmad Fatoum
2025-01-08 11:08 ` [PATCH] fixup! " Ahmad Fatoum
2025-01-08 14:23   ` (subset) " Sascha Hauer
2025-01-08 14:23 ` [PATCH 1/2] include: linux/iopoll.h: add optional PBL support Sascha Hauer
2025-01-08 15:43 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox