treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / arm64 / include / asm / vdso / gettimeofday.h
blobb08f476b72b4d917d93edc5c61bae1c6178bf5f5
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2018 ARM Limited
4 */
5 #ifndef __ASM_VDSO_GETTIMEOFDAY_H
6 #define __ASM_VDSO_GETTIMEOFDAY_H
8 #ifndef __ASSEMBLY__
10 #include <asm/unistd.h>
11 #include <uapi/linux/time.h>
13 #define __VDSO_USE_SYSCALL ULLONG_MAX
15 #define VDSO_HAS_CLOCK_GETRES 1
17 static __always_inline
18 int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
19 struct timezone *_tz)
21 register struct timezone *tz asm("x1") = _tz;
22 register struct __kernel_old_timeval *tv asm("x0") = _tv;
23 register long ret asm ("x0");
24 register long nr asm("x8") = __NR_gettimeofday;
26 asm volatile(
27 " svc #0\n"
28 : "=r" (ret)
29 : "r" (tv), "r" (tz), "r" (nr)
30 : "memory");
32 return ret;
35 static __always_inline
36 long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
38 register struct __kernel_timespec *ts asm("x1") = _ts;
39 register clockid_t clkid asm("x0") = _clkid;
40 register long ret asm ("x0");
41 register long nr asm("x8") = __NR_clock_gettime;
43 asm volatile(
44 " svc #0\n"
45 : "=r" (ret)
46 : "r" (clkid), "r" (ts), "r" (nr)
47 : "memory");
49 return ret;
52 static __always_inline
53 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
55 register struct __kernel_timespec *ts asm("x1") = _ts;
56 register clockid_t clkid asm("x0") = _clkid;
57 register long ret asm ("x0");
58 register long nr asm("x8") = __NR_clock_getres;
60 asm volatile(
61 " svc #0\n"
62 : "=r" (ret)
63 : "r" (clkid), "r" (ts), "r" (nr)
64 : "memory");
66 return ret;
69 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode)
71 u64 res;
74 * clock_mode == 0 implies that vDSO are enabled otherwise
75 * fallback on syscall.
77 if (clock_mode)
78 return __VDSO_USE_SYSCALL;
81 * This isb() is required to prevent that the counter value
82 * is speculated.
84 isb();
85 asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory");
87 * This isb() is required to prevent that the seq lock is
88 * speculated.#
90 isb();
92 return res;
95 static __always_inline
96 const struct vdso_data *__arch_get_vdso_data(void)
98 return _vdso_data;
101 #endif /* !__ASSEMBLY__ */
103 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */