treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / arm / include / asm / vdso / gettimeofday.h
blobfe6e1f65932d5fb363629a206d5e6cf18220f5b4
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/barrier.h>
11 #include <asm/cp15.h>
12 #include <asm/unistd.h>
13 #include <uapi/linux/time.h>
15 #define VDSO_HAS_CLOCK_GETRES 1
17 extern struct vdso_data *__get_datapage(void);
19 static __always_inline int gettimeofday_fallback(
20 struct __kernel_old_timeval *_tv,
21 struct timezone *_tz)
23 register struct timezone *tz asm("r1") = _tz;
24 register struct __kernel_old_timeval *tv asm("r0") = _tv;
25 register long ret asm ("r0");
26 register long nr asm("r7") = __NR_gettimeofday;
28 asm volatile(
29 " swi #0\n"
30 : "=r" (ret)
31 : "r" (tv), "r" (tz), "r" (nr)
32 : "memory");
34 return ret;
37 static __always_inline long clock_gettime_fallback(
38 clockid_t _clkid,
39 struct __kernel_timespec *_ts)
41 register struct __kernel_timespec *ts asm("r1") = _ts;
42 register clockid_t clkid asm("r0") = _clkid;
43 register long ret asm ("r0");
44 register long nr asm("r7") = __NR_clock_gettime64;
46 asm volatile(
47 " swi #0\n"
48 : "=r" (ret)
49 : "r" (clkid), "r" (ts), "r" (nr)
50 : "memory");
52 return ret;
55 static __always_inline long clock_gettime32_fallback(
56 clockid_t _clkid,
57 struct old_timespec32 *_ts)
59 register struct old_timespec32 *ts asm("r1") = _ts;
60 register clockid_t clkid asm("r0") = _clkid;
61 register long ret asm ("r0");
62 register long nr asm("r7") = __NR_clock_gettime;
64 asm volatile(
65 " swi #0\n"
66 : "=r" (ret)
67 : "r" (clkid), "r" (ts), "r" (nr)
68 : "memory");
70 return ret;
73 static __always_inline int clock_getres_fallback(
74 clockid_t _clkid,
75 struct __kernel_timespec *_ts)
77 register struct __kernel_timespec *ts asm("r1") = _ts;
78 register clockid_t clkid asm("r0") = _clkid;
79 register long ret asm ("r0");
80 register long nr asm("r7") = __NR_clock_getres_time64;
82 asm volatile(
83 " swi #0\n"
84 : "=r" (ret)
85 : "r" (clkid), "r" (ts), "r" (nr)
86 : "memory");
88 return ret;
91 static __always_inline int clock_getres32_fallback(
92 clockid_t _clkid,
93 struct old_timespec32 *_ts)
95 register struct old_timespec32 *ts asm("r1") = _ts;
96 register clockid_t clkid asm("r0") = _clkid;
97 register long ret asm ("r0");
98 register long nr asm("r7") = __NR_clock_getres;
100 asm volatile(
101 " swi #0\n"
102 : "=r" (ret)
103 : "r" (clkid), "r" (ts), "r" (nr)
104 : "memory");
106 return ret;
109 static __always_inline u64 __arch_get_hw_counter(int clock_mode)
111 #ifdef CONFIG_ARM_ARCH_TIMER
112 u64 cycle_now;
114 if (!clock_mode)
115 return -EINVAL;
117 isb();
118 cycle_now = read_sysreg(CNTVCT);
120 return cycle_now;
121 #else
122 return -EINVAL; /* use fallback */
123 #endif
126 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
128 return __get_datapage();
131 #endif /* !__ASSEMBLY__ */
133 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */