timekeeping_internal.h 780 B

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