Linux Audio

Check our new training course

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