diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2025-07-03 14:35:53 +0200 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2025-07-03 14:35:53 +0200 |
| commit | a6d9638d4da9740c189c141510584161ffd84307 (patch) | |
| tree | 905c1037b51f0cdff5a1dec3ec2999fe0f4f3bab /kernel/time | |
| parent | 7b95663a3d96b39b40f169dba5faef3e20163c5c (diff) | |
| parent | 5b605dbee07dda8fd538af1f07cbf1baf0a49cbc (diff) | |
Merge tag 'ktime-get-clock-ts64-for-ptp' into timers/ptp
Pull the base implementation of ktime_get_clock_ts64() for PTP, which
contains a temporary CLOCK_AUX* workaround. That was created to allow
integration of depending changes into the networking tree. The workaround
is going to be removed in a subsequent change in the timekeeping tree.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/time')
| -rw-r--r-- | kernel/time/timekeeping.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 6a61887eb87e..c6fe89bded02 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1641,6 +1641,40 @@ void ktime_get_raw_ts64(struct timespec64 *ts) EXPORT_SYMBOL(ktime_get_raw_ts64); /** + * ktime_get_clock_ts64 - Returns time of a clock in a timespec + * @id: POSIX clock ID of the clock to read + * @ts: Pointer to the timespec64 to be set + * + * The timestamp is invalidated (@ts->sec is set to -1) if the + * clock @id is not available. + */ +void ktime_get_clock_ts64(clockid_t id, struct timespec64 *ts) +{ + /* Invalidate time stamp */ + ts->tv_sec = -1; + ts->tv_nsec = 0; + + switch (id) { + case CLOCK_REALTIME: + ktime_get_real_ts64(ts); + return; + case CLOCK_MONOTONIC: + ktime_get_ts64(ts); + return; + case CLOCK_MONOTONIC_RAW: + ktime_get_raw_ts64(ts); + return; + case CLOCK_AUX ... CLOCK_AUX_LAST: + if (IS_ENABLED(CONFIG_POSIX_AUX_CLOCKS)) + ktime_get_aux_ts64(id, ts); + return; + default: + WARN_ON_ONCE(1); + } +} +EXPORT_SYMBOL_GPL(ktime_get_clock_ts64); + +/** * timekeeping_valid_for_hres - Check if timekeeping is suitable for hres */ int timekeeping_valid_for_hres(void) |
