• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TIMEKEEPING_INTERNAL_H
3 #define _TIMEKEEPING_INTERNAL_H
4 
5 #include <linux/clocksource.h>
6 #include <linux/spinlock.h>
7 #include <linux/time.h>
8 
9 /*
10  * timekeeping debug functions
11  */
12 #ifdef CONFIG_DEBUG_FS
13 extern void tk_debug_account_sleep_time(const struct timespec64 *t);
14 #else
15 #define tk_debug_account_sleep_time(x)
16 #endif
17 
clocksource_delta(u64 now,u64 last,u64 mask,u64 max_delta)18 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask, u64 max_delta)
19 {
20 	u64 ret = (now - last) & mask;
21 
22 	/*
23 	 * Prevent time going backwards by checking the result against
24 	 * @max_delta. If greater, return 0.
25 	 */
26 	return ret > max_delta ? 0 : ret;
27 }
28 
29 /* Semi public for serialization of non timekeeper VDSO updates. */
30 extern raw_spinlock_t timekeeper_lock;
31 
32 #endif /* _TIMEKEEPING_INTERNAL_H */
33