Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
5c83545f CC |
2 | #ifndef _TIMEKEEPING_INTERNAL_H |
3 | #define _TIMEKEEPING_INTERNAL_H | |
4 | /* | |
5 | * timekeeping debug functions | |
6 | */ | |
3a978377 | 7 | #include <linux/clocksource.h> |
5c83545f CC |
8 | #include <linux/time.h> |
9 | ||
10 | #ifdef CONFIG_DEBUG_FS | |
985e6950 | 11 | extern void tk_debug_account_sleep_time(const struct timespec64 *t); |
5c83545f CC |
12 | #else |
13 | #define tk_debug_account_sleep_time(x) | |
14 | #endif | |
15 | ||
09ec5442 | 16 | #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE |
a5a1d1c2 | 17 | static inline u64 clocksource_delta(u64 now, u64 last, u64 mask) |
09ec5442 | 18 | { |
a5a1d1c2 | 19 | u64 ret = (now - last) & mask; |
09ec5442 | 20 | |
1f45f1f3 YY |
21 | /* |
22 | * Prevent time going backwards by checking the MSB of mask in | |
23 | * the result. If set, return 0. | |
24 | */ | |
25 | return ret & ~(mask >> 1) ? 0 : ret; | |
09ec5442 TG |
26 | } |
27 | #else | |
a5a1d1c2 | 28 | static inline u64 clocksource_delta(u64 now, u64 last, u64 mask) |
3a978377 TG |
29 | { |
30 | return (now - last) & mask; | |
31 | } | |
09ec5442 | 32 | #endif |
3a978377 | 33 | |
5c83545f | 34 | #endif /* _TIMEKEEPING_INTERNAL_H */ |