From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ske@pengutronix.de, mtr@pengutronix.de,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/2] clock: make udelay(), get_time_ns() and is_timeout() weak aliases
Date: Wed, 9 Sep 2026 13:42:38 +0200 [thread overview]
Message-ID: <20260909114242.4099220-1-a.fatoum@pengutronix.de> (raw)
The ARM64 PBL is about to override these three for the time before a
clocksource is registered. Give the clocksource based implementations
names of their own and turn the generic ones into weak aliases, so an
override can still call the clocksource based version. No functional
change.
Assisted-by: Claude:fable-5.1
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/clock.c | 13 ++++++++++---
include/clock.h | 5 +++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/common/clock.c b/common/clock.c
index fc770ac8530f..0f2f47ed5399 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -50,7 +50,7 @@ late_initcall(dummy_csrc_warn);
/**
* get_time_ns - get current timestamp in nanoseconds
*/
-uint64_t get_time_ns(void)
+uint64_t clocksource_current_get_time_ns(void)
{
struct clocksource *cs = current_clock;
uint64_t cycle_now, cycle_delta;
@@ -73,6 +73,8 @@ uint64_t get_time_ns(void)
time_ns += ns_offset;
return time_ns;
}
+
+uint64_t get_time_ns(void) __weak __alias(clocksource_current_get_time_ns);
EXPORT_SYMBOL(get_time_ns);
/**
@@ -165,7 +167,7 @@ int is_timeout_non_interruptible(uint64_t start_ns, uint64_t time_offset_ns)
}
EXPORT_SYMBOL(is_timeout_non_interruptible);
-int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+int clocksource_current_is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
{
int ret = is_timeout_non_interruptible(start_ns, time_offset_ns);
@@ -174,6 +176,9 @@ int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
return ret;
}
+
+int is_timeout(uint64_t start_ns, uint64_t time_offset_ns)
+ __weak __alias(clocksource_current_is_timeout);
EXPORT_SYMBOL(is_timeout);
void ndelay(unsigned long nsecs)
@@ -184,12 +189,14 @@ void ndelay(unsigned long nsecs)
}
EXPORT_SYMBOL(ndelay);
-void udelay(unsigned long usecs)
+void clocksource_current_udelay(unsigned long usecs)
{
uint64_t start = get_time_ns();
while(!is_timeout(start, usecs * USECOND));
}
+
+void udelay(unsigned long usecs) __weak __alias(clocksource_current_udelay);
EXPORT_SYMBOL(udelay);
void mdelay(unsigned long msecs)
diff --git a/include/clock.h b/include/clock.h
index ca69535e9185..ea87bfd2020a 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -58,6 +58,11 @@ void udelay(unsigned long usecs);
void mdelay(unsigned long msecs);
void mdelay_non_interruptible(unsigned long msecs);
+/* the clocksource based implementations the weak functions above alias */
+void clocksource_current_udelay(unsigned long usecs);
+uint64_t clocksource_current_get_time_ns(void);
+int clocksource_current_is_timeout(uint64_t start_ns, uint64_t time_offset_ns);
+
#if IN_PROPER
void clocksource_srand(void);
#else
--
2.47.3
next reply other threads:[~2026-09-09 12:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 11:42 Ahmad Fatoum [this message]
2026-09-09 11:42 ` [PATCH master 2/2] ARM64: fall back to reading the counter directly in the PBL udelay() 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=20260909114242.4099220-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=mtr@pengutronix.de \
--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