From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/4] include: linux/iopoll.h: evaluate timeout_us argument only once
Date: Wed, 2 Jul 2025 13:01:36 +0200 [thread overview]
Message-ID: <20250702110139.2235318-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250702110139.2235318-1-a.fatoum@pengutronix.de>
We currently evaluate timeout_us three times, which is unexpected and
suboptimal when having complexer timeout calculations.
Define a local variable to fix this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/linux/iopoll.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index c38190272606..a6fade2a11fc 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -20,7 +20,7 @@
# 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)
+# define read_poll_is_timeout(s, t) ((void)(s), (void)(t), 0)
# endif
#endif
@@ -43,13 +43,14 @@
*/
#define read_poll_timeout(op, val, cond, timeout_us, args...) \
({ \
- uint64_t start = (timeout_us) != 0 ? read_poll_get_time_ns() : 0; \
+ uint64_t __timeout_us = (timeout_us); \
+ uint64_t start = __timeout_us ? read_poll_get_time_ns() : 0; \
for (;;) { \
(val) = op(args); \
if (cond) \
break; \
- if ((timeout_us) != 0 && \
- read_poll_is_timeout(start, ((timeout_us) * USECOND))) { \
+ if (__timeout_us && \
+ read_poll_is_timeout(start, __timeout_us * USECOND)) { \
(val) = op(args); \
break; \
} \
--
2.39.5
next prev parent reply other threads:[~2025-07-02 12:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 11:01 [PATCH 0/4] mci: clean up MCI idle delay handling a bit Ahmad Fatoum
2025-07-02 11:01 ` Ahmad Fatoum [this message]
2025-07-02 11:01 ` [PATCH 2/4] mci: bcm2835: allow core to request timeouts longer than 100ms Ahmad Fatoum
2025-07-02 11:01 ` [PATCH 3/4] mci: sdhci: use sdhci_compute_timeout in sdhci_wait_idle[_data] Ahmad Fatoum
2025-07-02 11:01 ` [PATCH 4/4] mci: sdhci: reduce duplication " Ahmad Fatoum
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=20250702110139.2235318-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.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