1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TIMEKEEPING_INTERNAL_H
3 #define _TIMEKEEPING_INTERNAL_H
5 #include <linux/clocksource.h>
6 #include <linux/spinlock.h>
7 #include <linux/time.h>
10 * timekeeping debug functions
12 #ifdef CONFIG_DEBUG_FS
13 extern void tk_debug_account_sleep_time(const struct timespec64 *t);
15 #define tk_debug_account_sleep_time(x)
18 #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
19 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
21 u64 ret = (now - last) & mask;
24 * Prevent time going backwards by checking the MSB of mask in
25 * the result. If set, return 0.
27 return ret & ~(mask >> 1) ? 0 : ret;
30 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
32 return (now - last) & mask;
36 /* Semi public for serialization of non timekeeper VDSO updates. */
37 extern raw_spinlock_t timekeeper_lock;
39 #endif /* _TIMEKEEPING_INTERNAL_H */