From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ske@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] include: linux/iopoll.h: add optional PBL support
Date: Wed, 8 Jan 2025 12:04:19 +0100 [thread overview]
Message-ID: <20250108110420.1850995-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2025-01-08 11:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 11:04 Ahmad Fatoum [this message]
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
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=20250108110420.1850995-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=ske@pengutronix.de \
/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