mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh (Schneider Electric)" <thomas.weissschuh@linutronix.de>
To: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	 Frederic Weisbecker <frederic@kernel.org>,
	 Thomas Gleixner <tglx@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	"Thomas Weißschuh (Schneider Electric)"
	<thomas.weissschuh@linutronix.de>
Subject: [PATCH 3/8] hrtimer: Move hrtimer_update_function() to hrtimer.c
Date: Thu, 02 Jul 2026 11:42:00 +0200	[thread overview]
Message-ID: <20260702-hrtimer-header-dependencies-v1-3-c50b19bda473@linutronix.de> (raw)
In-Reply-To: <20260702-hrtimer-header-dependencies-v1-0-c50b19bda473@linutronix.de>

The usage of the timer 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@linutronix.de>
---
 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 7bf154cf3079..81ab9849e83b 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 313dcea127fe..31d09bc84ed7 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1039,6 +1039,30 @@ static inline void unlock_hrtimer_base(const struct hrtimer *timer, unsigned lon
 	raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags);
 }
 
+/**
+ * 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

-- 
2.55.0


  parent reply	other threads:[~2026-07-02  9:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  9:41 [PATCH 0/8] hrtimer: Untangle base definitions from hrtimer.h Thomas Weißschuh (Schneider Electric)
2026-07-02  9:41 ` [PATCH 1/8] hrtimer: Rename hrtimer_defs.h to hrtimer_bases.h Thomas Weißschuh (Schneider Electric)
2026-07-07 21:49   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-07-02  9:41 ` [PATCH 2/8] hrtimer: Move hrtimer_callback_running() " Thomas Weißschuh (Schneider Electric)
2026-07-07 21:49   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-07-02  9:42 ` Thomas Weißschuh (Schneider Electric) [this message]
2026-07-07 21:49   ` [tip: timers/core] hrtimer: Move hrtimer_update_function() to hrtimer.c tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-07-02  9:42 ` [PATCH 4/8] tick: Explicitly include linux/hrtimer_bases.h Thomas Weißschuh (Schneider Electric)
2026-07-07 21:49   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-07-02  9:42 ` [PATCH 5/8] hrtimer: " Thomas Weißschuh (Schneider Electric)
2026-07-07 21:49   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-07-02  9:42 ` [PATCH 6/8] hrtimer: Explicitly include some necessary headers in hrtimer_rearm.h Thomas Weißschuh (Schneider Electric)
2026-07-07 21:49   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-07-02  9:42 ` [PATCH 7/8] x86/speculation: Explicitly include linux/types.h Thomas Weißschuh (Schneider Electric)
2026-07-07 21:49   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-07-02  9:42 ` [PATCH 8/8] hrtimer: Remove inclusion of hrtimer_bases.h remove from hrtimer.h Thomas Weißschuh (Schneider Electric)
2026-07-07 21:49   ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)

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=20260702-hrtimer-header-dependencies-v1-3-c50b19bda473@linutronix.de \
    --to=thomas.weissschuh@linutronix.de \
    --cc=anna-maria@linutronix.de \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@kernel.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

all inboxes | Powered by JetHome®