[tip: timers/core] hrtimer: Move hrtimer_update_function() to hrtimer.c

From: tip-bot2 for Thomas Weißschuh (Schneider Electric)

Date: Tue Jul 07 2026 - 17:51:06 EST


The following commit has been merged into the timers/core branch of tip:

Commit-ID: a116c7582d7f7701736801a47e3432eb7cabd674
Gitweb: https://git.kernel.org/tip/a116c7582d7f7701736801a47e3432eb7cabd674
Author: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@xxxxxxxxxxxxx>
AuthorDate: Thu, 02 Jul 2026 11:42:00 +02:00
Committer: Thomas Gleixner <tglx@xxxxxxxxxx>
CommitterDate: Tue, 07 Jul 2026 23:43:44 +02:00

hrtimer: Move hrtimer_update_function() to hrtimer.c

The usage of the hrtimer base forces hrtimer.h to also expose the base
structure definitions.

Move the function to hrtimer.c to avoid this.

Signed-off-by: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@xxxxxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://patch.msgid.link/20260702-hrtimer-header-dependencies-v1-3-c50b19bda473@xxxxxxxxxxxxx
---
include/linux/hrtimer.h | 24 ++----------------------
kernel/time/hrtimer.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 7bf154c..81ab984 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -287,28 +287,8 @@ static inline bool hrtimer_is_queued(struct hrtimer *timer)
return READ_ONCE(timer->is_queued);
}

-/**
- * hrtimer_update_function - Update the timer's callback function
- * @timer: Timer to update
- * @function: New callback function
- *
- * Only safe to call if the timer is not enqueued. Can be called in the callback function if the
- * timer is not enqueued at the same time (see the comments above HRTIMER_STATE_ENQUEUED).
- */
-static inline void hrtimer_update_function(struct hrtimer *timer,
- enum hrtimer_restart (*function)(struct hrtimer *))
-{
-#ifdef CONFIG_PROVE_LOCKING
- guard(raw_spinlock_irqsave)(&timer->base->cpu_base->lock);
-
- if (WARN_ON_ONCE(hrtimer_is_queued(timer)))
- return;
-
- if (WARN_ON_ONCE(!function))
- return;
-#endif
- ACCESS_PRIVATE(timer, function) = function;
-}
+void hrtimer_update_function(struct hrtimer *timer,
+ enum hrtimer_restart (*function)(struct hrtimer *));

/* Forward a hrtimer so it expires after now: */
extern u64
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 697816d..0ac8899 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1040,6 +1040,30 @@ static inline void unlock_hrtimer_base(const struct hrtimer *timer, unsigned lon
}

/**
+ * hrtimer_update_function - Update the timer's callback function
+ * @timer: Timer to update
+ * @function: New callback function
+ *
+ * Only safe to call if the timer is not enqueued. Can be called in the callback function if the
+ * timer is not enqueued at the same time (see the comments above HRTIMER_STATE_ENQUEUED).
+ */
+void hrtimer_update_function(struct hrtimer *timer,
+ enum hrtimer_restart (*function)(struct hrtimer *))
+{
+#ifdef CONFIG_PROVE_LOCKING
+ guard(raw_spinlock_irqsave)(&timer->base->cpu_base->lock);
+
+ if (WARN_ON_ONCE(hrtimer_is_queued(timer)))
+ return;
+
+ if (WARN_ON_ONCE(!function))
+ return;
+#endif
+ ACCESS_PRIVATE(timer, function) = function;
+}
+EXPORT_SYMBOL_GPL(hrtimer_update_function);
+
+/**
* hrtimer_forward() - forward the timer expiry
* @timer: hrtimer to forward
* @now: forward past this time