Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _TIMEKEEPING_INTERNAL_H
0003 #define _TIMEKEEPING_INTERNAL_H
0004 
0005 #include <linux/clocksource.h>
0006 #include <linux/spinlock.h>
0007 #include <linux/time.h>
0008 
0009 /*
0010  * timekeeping debug functions
0011  */
0012 #ifdef CONFIG_DEBUG_FS
0013 extern void tk_debug_account_sleep_time(const struct timespec64 *t);
0014 #else
0015 #define tk_debug_account_sleep_time(x)
0016 #endif
0017 
0018 #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE
0019 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
0020 {
0021     u64 ret = (now - last) & mask;
0022 
0023     /*
0024      * Prevent time going backwards by checking the MSB of mask in
0025      * the result. If set, return 0.
0026      */
0027     return ret & ~(mask >> 1) ? 0 : ret;
0028 }
0029 #else
0030 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
0031 {
0032     return (now - last) & mask;
0033 }
0034 #endif
0035 
0036 /* Semi public for serialization of non timekeeper VDSO updates. */
0037 extern raw_spinlock_t timekeeper_lock;
0038 
0039 #endif /* _TIMEKEEPING_INTERNAL_H */