* [PATCH] include: linux/iopoll.h: add optional PBL support
@ 2025-04-22 7:55 Ahmad Fatoum
2025-04-22 9:22 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-04-22 7:55 UTC (permalink / raw)
To: barebox; +Cc: 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>
---
v1 -> v2:
- compare timeout_us against 0 to fix warnings when it contains
a multiplication.
---
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..61d8f4714e97 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) == 0 ? 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] 2+ messages in thread
end of thread, other threads:[~2025-04-22 10:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-22 7:55 [PATCH] include: linux/iopoll.h: add optional PBL support Ahmad Fatoum
2025-04-22 9:22 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox