[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250513145138.095772163@linutronix.de>
Date: Tue, 13 May 2025 17:13:39 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: netdev@...r.kernel.org,
Richard Cochran <richardcochran@...il.com>,
Christopher Hall <christopher.s.hall@...el.com>,
David Zage <david.zage@...el.com>,
John Stultz <jstultz@...gle.com>,
Frederic Weisbecker <frederic@...nel.org>,
Anna-Maria Behnsen <anna-maria@...utronix.de>,
Miroslav Lichvar <mlichvar@...hat.com>,
Werner Abt <werner.abt@...nberg-usa.com>,
David Woodhouse <dwmw2@...radead.org>,
Stephen Boyd <sboyd@...nel.org>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>,
Kurt Kanzenbach <kurt@...utronix.de>,
Nam Cao <namcao@...utronix.de>,
Alex Gieringer <gieri@...utronix.de>
Subject: [patch 24/26] timekeeping: Provide adjtimex() for PTP clocks
The behaviour is close to clock_adtime(CLOCK_REALTIME) with the
following differences:
1) ADJ_SETOFFSET adjusts the PTP 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@...utronix.de>
---
kernel/time/timekeeping.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -2862,10 +2862,26 @@ static int ptp_clock_set(const clockid_t
return 0;
}
+static int ptp_clock_adj(const clockid_t id, struct __kernel_timex *txc)
+{
+ struct tk_data *tkd = ptp_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 these PTP clocks.
+ */
+ return __do_adjtimex(tkd, txc, &result);
+}
+
const struct k_clock clock_ptp = {
.clock_getres = ptp_get_res,
.clock_get_timespec = ptp_get_timespec,
.clock_set = ptp_clock_set,
+ .clock_adj = ptp_clock_adj,
};
static __init void tk_ptp_setup(void)
Powered by blists - more mailing lists