Merge remote-tracking branch 'spi/for-5.12' into spi-linus
[linux-2.6-microblaze.git] / arch / s390 / include / asm / vdso / gettimeofday.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ASM_VDSO_GETTIMEOFDAY_H
3 #define ASM_VDSO_GETTIMEOFDAY_H
4
5 #define VDSO_HAS_TIME 1
6
7 #define VDSO_HAS_CLOCK_GETRES 1
8
9 #include <asm/timex.h>
10 #include <asm/unistd.h>
11 #include <asm/vdso.h>
12 #include <linux/compiler.h>
13
14 #define vdso_calc_delta __arch_vdso_calc_delta
15 static __always_inline u64 __arch_vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
16 {
17         return (cycles - last) * mult;
18 }
19
20 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
21 {
22         return _vdso_data;
23 }
24
25 static inline u64 __arch_get_hw_counter(s32 clock_mode, const struct vdso_data *vd)
26 {
27         u64 adj, now;
28
29         now = get_tod_clock();
30         adj = vd->arch_data.tod_steering_end - now;
31         if (unlikely((s64) adj > 0))
32                 now += (vd->arch_data.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
33         return now;
34 }
35
36 static __always_inline
37 long clock_gettime_fallback(clockid_t clkid, struct __kernel_timespec *ts)
38 {
39         register unsigned long r1 __asm__("r1") = __NR_clock_gettime;
40         register unsigned long r2 __asm__("r2") = (unsigned long)clkid;
41         register void *r3 __asm__("r3") = ts;
42
43         asm ("svc 0\n" : "+d" (r2) : "d" (r1), "d" (r3) : "cc", "memory");
44         return r2;
45 }
46
47 static __always_inline
48 long gettimeofday_fallback(register struct __kernel_old_timeval *tv,
49                            register struct timezone *tz)
50 {
51         register unsigned long r1 __asm__("r1") = __NR_gettimeofday;
52         register unsigned long r2 __asm__("r2") = (unsigned long)tv;
53         register void *r3 __asm__("r3") = tz;
54
55         asm ("svc 0\n" : "+d" (r2) : "d" (r1), "d" (r3) : "cc", "memory");
56         return r2;
57 }
58
59 static __always_inline
60 long clock_getres_fallback(clockid_t clkid, struct __kernel_timespec *ts)
61 {
62         register unsigned long r1 __asm__("r1") = __NR_clock_getres;
63         register unsigned long r2 __asm__("r2") = (unsigned long)clkid;
64         register void *r3 __asm__("r3") = ts;
65
66         asm ("svc 0\n" : "+d" (r2) : "d" (r1), "d" (r3) : "cc", "memory");
67         return r2;
68 }
69
70 #ifdef CONFIG_TIME_NS
71 static __always_inline
72 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
73 {
74         return _timens_data;
75 }
76 #endif
77
78 #endif