]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
timekeeping: Make __timekeeping_advance() reusable
authorAnna-Maria Behnsen <anna-maria@linutronix.de>
Mon, 19 May 2025 08:33:25 +0000 (10:33 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 19 Jun 2025 12:28:23 +0000 (14:28 +0200)
In __timekeeping_advance() the pointer to struct tk_data is hardcoded by the
use of &tk_core. As long as there is only a single timekeeper (tk_core),
this is not a problem. But when __timekeeping_advance() will be reused for
per auxiliary timekeepers, __timekeeping_advance() needs to be generalized.

Add a pointer to struct tk_data as function argument of
__timekeeping_advance() and adapt all call sites.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/all/20250519083026.160967312@linutronix.de
kernel/time/timekeeping.c

index 99b4749f066553006fda958cde3833327e97c78e..153f760dffb4e7dcc7db0abdf9a6346693ed3398 100644 (file)
@@ -2196,10 +2196,10 @@ static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset,
  * timekeeping_advance - Updates the timekeeper to the current time and
  * current NTP tick length
  */
-static bool __timekeeping_advance(enum timekeeping_adv_mode mode)
+static bool __timekeeping_advance(struct tk_data *tkd, enum timekeeping_adv_mode mode)
 {
-       struct timekeeper *tk = &tk_core.shadow_timekeeper;
-       struct timekeeper *real_tk = &tk_core.timekeeper;
+       struct timekeeper *tk = &tkd->shadow_timekeeper;
+       struct timekeeper *real_tk = &tkd->timekeeper;
        unsigned int clock_set = 0;
        int shift = 0, maxshift;
        u64 offset, orig_offset;
@@ -2252,7 +2252,7 @@ static bool __timekeeping_advance(enum timekeeping_adv_mode mode)
        if (orig_offset != offset)
                tk_update_coarse_nsecs(tk);
 
-       timekeeping_update_from_shadow(&tk_core, clock_set);
+       timekeeping_update_from_shadow(tkd, clock_set);
 
        return !!clock_set;
 }
@@ -2260,7 +2260,7 @@ static bool __timekeeping_advance(enum timekeeping_adv_mode mode)
 static bool timekeeping_advance(enum timekeeping_adv_mode mode)
 {
        guard(raw_spinlock_irqsave)(&tk_core.lock);
-       return __timekeeping_advance(mode);
+       return __timekeeping_advance(&tk_core, mode);
 }
 
 /**
@@ -2598,7 +2598,7 @@ int do_adjtimex(struct __kernel_timex *txc)
 
                /* Update the multiplier immediately if frequency was set directly */
                if (txc->modes & (ADJ_FREQUENCY | ADJ_TICK))
-                       clock_set |= __timekeeping_advance(TK_ADV_FREQ);
+                       clock_set |= __timekeeping_advance(&tk_core, TK_ADV_FREQ);
        }
 
        if (txc->modes & ADJ_SETOFFSET)