]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/timekeeping32.h
regulator: ab8500: Remove AB8505 USB regulator
[mirror_ubuntu-bionic-kernel.git] / include / linux / timekeeping32.h
1 #ifndef _LINUX_TIMEKEEPING32_H
2 #define _LINUX_TIMEKEEPING32_H
3 /*
4 * These interfaces are all based on the old timespec type
5 * and should get replaced with the timespec64 based versions
6 * over time so we can remove the file here.
7 */
8
9 static inline void do_gettimeofday(struct timeval *tv)
10 {
11 struct timespec64 now;
12
13 ktime_get_real_ts64(&now);
14 tv->tv_sec = now.tv_sec;
15 tv->tv_usec = now.tv_nsec/1000;
16 }
17
18 static inline unsigned long get_seconds(void)
19 {
20 return ktime_get_real_seconds();
21 }
22
23 /* does not take xtime_lock */
24 struct timespec __current_kernel_time(void);
25
26 static inline struct timespec current_kernel_time(void)
27 {
28 struct timespec64 now = current_kernel_time64();
29
30 return timespec64_to_timespec(now);
31 }
32
33 #if BITS_PER_LONG == 64
34 /**
35 * Deprecated. Use do_settimeofday64().
36 */
37 static inline int do_settimeofday(const struct timespec *ts)
38 {
39 return do_settimeofday64(ts);
40 }
41
42 static inline int __getnstimeofday(struct timespec *ts)
43 {
44 return __getnstimeofday64(ts);
45 }
46
47 static inline void getnstimeofday(struct timespec *ts)
48 {
49 getnstimeofday64(ts);
50 }
51
52 static inline void ktime_get_ts(struct timespec *ts)
53 {
54 ktime_get_ts64(ts);
55 }
56
57 static inline void ktime_get_real_ts(struct timespec *ts)
58 {
59 getnstimeofday64(ts);
60 }
61
62 static inline void getrawmonotonic(struct timespec *ts)
63 {
64 getrawmonotonic64(ts);
65 }
66
67 static inline struct timespec get_monotonic_coarse(void)
68 {
69 return get_monotonic_coarse64();
70 }
71
72 static inline void getboottime(struct timespec *ts)
73 {
74 return getboottime64(ts);
75 }
76 #else
77 /**
78 * Deprecated. Use do_settimeofday64().
79 */
80 static inline int do_settimeofday(const struct timespec *ts)
81 {
82 struct timespec64 ts64;
83
84 ts64 = timespec_to_timespec64(*ts);
85 return do_settimeofday64(&ts64);
86 }
87
88 static inline int __getnstimeofday(struct timespec *ts)
89 {
90 struct timespec64 ts64;
91 int ret = __getnstimeofday64(&ts64);
92
93 *ts = timespec64_to_timespec(ts64);
94 return ret;
95 }
96
97 static inline void getnstimeofday(struct timespec *ts)
98 {
99 struct timespec64 ts64;
100
101 getnstimeofday64(&ts64);
102 *ts = timespec64_to_timespec(ts64);
103 }
104
105 static inline void ktime_get_ts(struct timespec *ts)
106 {
107 struct timespec64 ts64;
108
109 ktime_get_ts64(&ts64);
110 *ts = timespec64_to_timespec(ts64);
111 }
112
113 static inline void ktime_get_real_ts(struct timespec *ts)
114 {
115 struct timespec64 ts64;
116
117 getnstimeofday64(&ts64);
118 *ts = timespec64_to_timespec(ts64);
119 }
120
121 static inline void getrawmonotonic(struct timespec *ts)
122 {
123 struct timespec64 ts64;
124
125 getrawmonotonic64(&ts64);
126 *ts = timespec64_to_timespec(ts64);
127 }
128
129 static inline struct timespec get_monotonic_coarse(void)
130 {
131 return timespec64_to_timespec(get_monotonic_coarse64());
132 }
133
134 static inline void getboottime(struct timespec *ts)
135 {
136 struct timespec64 ts64;
137
138 getboottime64(&ts64);
139 *ts = timespec64_to_timespec(ts64);
140 }
141 #endif
142
143 /*
144 * Timespec interfaces utilizing the ktime based ones
145 */
146 static inline void get_monotonic_boottime(struct timespec *ts)
147 {
148 *ts = ktime_to_timespec(ktime_get_boottime());
149 }
150
151 static inline void timekeeping_clocktai(struct timespec *ts)
152 {
153 *ts = ktime_to_timespec(ktime_get_clocktai());
154 }
155
156 /*
157 * Persistent clock related interfaces
158 */
159 extern void read_persistent_clock(struct timespec *ts);
160 extern int update_persistent_clock(struct timespec now);
161
162 #endif