[patch V2 24/26] timekeeping: Provide adjtimex() for auxiliary clocks

From: Thomas Gleixner
Date: Mon May 19 2025 - 04:42:06 EST


The behaviour is close to clock_adtime(CLOCK_REALTIME) with the
following differences:

1) ADJ_SETOFFSET adjusts the auxiliary clock offset

2) ADJ_TAI is not supported

3) Leap seconds are not supported

4) PPS is not supported

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
kernel/time/timekeeping.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2860,10 +2860,26 @@ static int aux_clock_set(const clockid_t
return 0;
}

+static int aux_clock_adj(const clockid_t id, struct __kernel_timex *txc)
+{
+ struct tk_data *tkd = aux_get_tk_data(id);
+ struct adjtimex_result result = { };
+
+ if (!tkd)
+ return -ENODEV;
+
+ /*
+ * @result is ignored for now as there are neither hrtimers nor a
+ * RTC related to auxiliary clocks for now.
+ */
+ return __do_adjtimex(tkd, txc, &result);
+}
+
const struct k_clock clock_aux = {
.clock_getres = aux_get_res,
.clock_get_timespec = aux_get_timespec,
.clock_set = aux_clock_set,
+ .clock_adj = aux_clock_adj,
};

static __init void tk_aux_setup(void)