Merge branch 'rework/printk_safe-removal' into for-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 <linux/compiler.h>
12
13 #define vdso_calc_delta __arch_vdso_calc_delta
14 static __always_inline u64 __arch_vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult)
15 {
16         return (cycles - last) * mult;
17 }
18
19 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
20 {
21         return _vdso_data;
22 }
23
24 static inline u64 __arch_get_hw_counter(s32 clock_mode, const struct vdso_data *vd)
25 {
26         u64 adj, now;
27
28         now = get_tod_clock();
29         adj = vd->arch_data.tod_steering_end - now;
30         if (unlikely((s64) adj > 0))
31                 now += (vd->arch_data.tod_steering_delta < 0) ? (adj >> 15) : -(adj >> 15);
32         return now;
33 }
34
35 static __always_inline
36 long clock_gettime_fallback(clockid_t clkid, struct __kernel_timespec *ts)
37 {
38         register unsigned long r1 __asm__("r1") = __NR_clock_gettime;
39         register unsigned long r2 __asm__("r2") = (unsigned long)clkid;
40         register void *r3 __asm__("r3") = ts;
41
42         asm ("svc 0\n" : "+d" (r2) : "d" (r1), "d" (r3) : "cc", "memory");
43         return r2;
44 }
45
46 static __always_inline
47 long gettimeofday_fallback(register struct __kernel_old_timeval *tv,
48                            register struct timezone *tz)
49 {
50         register unsigned long r1 __asm__("r1") = __NR_gettimeofday;
51         register unsigned long r2 __asm__("r2") = (unsigned long)tv;
52         register void *r3 __asm__("r3") = tz;
53
54         asm ("svc 0\n" : "+d" (r2) : "d" (r1), "d" (r3) : "cc", "memory");
55         return r2;
56 }
57
58 static __always_inline
59 long clock_getres_fallback(clockid_t clkid, struct __kernel_timespec *ts)
60 {
61         register unsigned long r1 __asm__("r1") = __NR_clock_getres;
62         register unsigned long r2 __asm__("r2") = (unsigned long)clkid;
63         register void *r3 __asm__("r3") = ts;
64
65         asm ("svc 0\n" : "+d" (r2) : "d" (r1), "d" (r3) : "cc", "memory");
66         return r2;
67 }
68
69 #ifdef CONFIG_TIME_NS
70 static __always_inline
71 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
72 {
73         return _timens_data;
74 }
75 #endif
76
77 #endif