aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-10-19 07:14:49 -0400
committerJohn Stultz <john.stultz@linaro.org>2017-10-30 18:17:20 -0400
commit6546911ed369af8d747215ff8b6144618e91c6ab (patch)
treedd207663bb415a316ca37641d4c719a07ac0f32e
parentabc8f96e3eb846fcf6333395ee1f6ed4a734576c (diff)
time: Move old timekeeping interfaces to timekeeping32.h
The interfaces based on 'struct timespec' and 'unsigned long' seconds are no longer recommended for new code, and we are trying to migrate to ktime_t based interfaces and other y2038-safe variants. This moves all the legacy interfaces from linux/timekeeping.h into a new timekeeping32.h to better document this. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Miroslav Lichvar <mlichvar@redhat.com> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Cc: Stephen Boyd <stephen.boyd@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r--include/linux/ktime.h1
-rw-r--r--include/linux/timekeeping.h137
-rw-r--r--include/linux/timekeeping32.h151
3 files changed, 154 insertions, 135 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 0c8bd45c8206..5b9fddbaac41 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -270,5 +270,6 @@ static inline ktime_t ms_to_ktime(u64 ms)
270} 270}
271 271
272# include <linux/timekeeping.h> 272# include <linux/timekeeping.h>
273# include <linux/timekeeping32.h>
273 274
274#endif 275#endif
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index ddc229ff6d1e..405beea4e71b 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -15,27 +15,16 @@ extern void xtime_update(unsigned long ticks);
15/* 15/*
16 * Get and set timeofday 16 * Get and set timeofday
17 */ 17 */
18extern void do_gettimeofday(struct timeval *tv);
19extern int do_settimeofday64(const struct timespec64 *ts); 18extern int do_settimeofday64(const struct timespec64 *ts);
20extern int do_sys_settimeofday64(const struct timespec64 *tv, 19extern int do_sys_settimeofday64(const struct timespec64 *tv,
21 const struct timezone *tz); 20 const struct timezone *tz);
22/* 21/*
23 * Kernel time accessors 22 * Kernel time accessors
24 */ 23 */
25unsigned long get_seconds(void);
26struct timespec64 current_kernel_time64(void); 24struct timespec64 current_kernel_time64(void);
27/* does not take xtime_lock */
28struct timespec __current_kernel_time(void);
29
30static inline struct timespec current_kernel_time(void)
31{
32 struct timespec64 now = current_kernel_time64();
33
34 return timespec64_to_timespec(now);
35}
36 25
37/* 26/*
38 * timespec based interfaces 27 * timespec64 based interfaces
39 */ 28 */
40struct timespec64 get_monotonic_coarse64(void); 29struct timespec64 get_monotonic_coarse64(void);
41extern void getrawmonotonic64(struct timespec64 *ts); 30extern void getrawmonotonic64(struct timespec64 *ts);
@@ -47,116 +36,6 @@ extern int __getnstimeofday64(struct timespec64 *tv);
47extern void getnstimeofday64(struct timespec64 *tv); 36extern void getnstimeofday64(struct timespec64 *tv);
48extern void getboottime64(struct timespec64 *ts); 37extern void getboottime64(struct timespec64 *ts);
49 38
50#if BITS_PER_LONG == 64
51/**
52 * Deprecated. Use do_settimeofday64().
53 */
54static inline int do_settimeofday(const struct timespec *ts)
55{
56 return do_settimeofday64(ts);
57}
58
59static inline int __getnstimeofday(struct timespec *ts)
60{
61 return __getnstimeofday64(ts);
62}
63
64static inline void getnstimeofday(struct timespec *ts)
65{
66 getnstimeofday64(ts);
67}
68
69static inline void ktime_get_ts(struct timespec *ts)
70{
71 ktime_get_ts64(ts);
72}
73
74static inline void ktime_get_real_ts(struct timespec *ts)
75{
76 getnstimeofday64(ts);
77}
78
79static inline void getrawmonotonic(struct timespec *ts)
80{
81 getrawmonotonic64(ts);
82}
83
84static inline struct timespec get_monotonic_coarse(void)
85{
86 return get_monotonic_coarse64();
87}
88
89static inline void getboottime(struct timespec *ts)
90{
91 return getboottime64(ts);
92}
93#else
94/**
95 * Deprecated. Use do_settimeofday64().
96 */
97static inline int do_settimeofday(const struct timespec *ts)
98{
99 struct timespec64 ts64;
100
101 ts64 = timespec_to_timespec64(*ts);
102 return do_settimeofday64(&ts64);
103}
104
105static inline int __getnstimeofday(struct timespec *ts)
106{
107 struct timespec64 ts64;
108 int ret = __getnstimeofday64(&ts64);
109
110 *ts = timespec64_to_timespec(ts64);
111 return ret;
112}
113
114static inline void getnstimeofday(struct timespec *ts)
115{
116 struct timespec64 ts64;
117
118 getnstimeofday64(&ts64);
119 *ts = timespec64_to_timespec(ts64);
120}
121
122static inline void ktime_get_ts(struct timespec *ts)
123{
124 struct timespec64 ts64;
125
126 ktime_get_ts64(&ts64);
127 *ts = timespec64_to_timespec(ts64);
128}
129
130static inline void ktime_get_real_ts(struct timespec *ts)
131{
132 struct timespec64 ts64;
133
134 getnstimeofday64(&ts64);
135 *ts = timespec64_to_timespec(ts64);
136}
137
138static inline void getrawmonotonic(struct timespec *ts)
139{
140 struct timespec64 ts64;
141
142 getrawmonotonic64(&ts64);
143 *ts = timespec64_to_timespec(ts64);
144}
145
146static inline struct timespec get_monotonic_coarse(void)
147{
148 return timespec64_to_timespec(get_monotonic_coarse64());
149}
150
151static inline void getboottime(struct timespec *ts)
152{
153 struct timespec64 ts64;
154
155 getboottime64(&ts64);
156 *ts = timespec64_to_timespec(ts64);
157}
158#endif
159
160#define ktime_get_real_ts64(ts) getnstimeofday64(ts) 39#define ktime_get_real_ts64(ts) getnstimeofday64(ts)
161 40
162/* 41/*
@@ -241,23 +120,13 @@ extern u64 ktime_get_raw_fast_ns(void);
241extern u64 ktime_get_boot_fast_ns(void); 120extern u64 ktime_get_boot_fast_ns(void);
242 121
243/* 122/*
244 * Timespec interfaces utilizing the ktime based ones 123 * timespec64 interfaces utilizing the ktime based ones
245 */ 124 */
246static inline void get_monotonic_boottime(struct timespec *ts)
247{
248 *ts = ktime_to_timespec(ktime_get_boottime());
249}
250
251static inline void get_monotonic_boottime64(struct timespec64 *ts) 125static inline void get_monotonic_boottime64(struct timespec64 *ts)
252{ 126{
253 *ts = ktime_to_timespec64(ktime_get_boottime()); 127 *ts = ktime_to_timespec64(ktime_get_boottime());
254} 128}
255 129
256static inline void timekeeping_clocktai(struct timespec *ts)
257{
258 *ts = ktime_to_timespec(ktime_get_clocktai());
259}
260
261static inline void timekeeping_clocktai64(struct timespec64 *ts) 130static inline void timekeeping_clocktai64(struct timespec64 *ts)
262{ 131{
263 *ts = ktime_to_timespec64(ktime_get_clocktai()); 132 *ts = ktime_to_timespec64(ktime_get_clocktai());
@@ -340,10 +209,8 @@ extern void ktime_get_snapshot(struct system_time_snapshot *systime_snapshot);
340 */ 209 */
341extern int persistent_clock_is_local; 210extern int persistent_clock_is_local;
342 211
343extern void read_persistent_clock(struct timespec *ts);
344extern void read_persistent_clock64(struct timespec64 *ts); 212extern void read_persistent_clock64(struct timespec64 *ts);
345extern void read_boot_clock64(struct timespec64 *ts); 213extern void read_boot_clock64(struct timespec64 *ts);
346extern int update_persistent_clock(struct timespec now);
347extern int update_persistent_clock64(struct timespec64 now); 214extern int update_persistent_clock64(struct timespec64 now);
348 215
349 216
diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h
new file mode 100644
index 000000000000..af4114d5dc17
--- /dev/null
+++ b/include/linux/timekeeping32.h
@@ -0,0 +1,151 @@
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
9extern void do_gettimeofday(struct timeval *tv);
10unsigned long get_seconds(void);
11
12/* does not take xtime_lock */
13struct timespec __current_kernel_time(void);
14
15static inline struct timespec current_kernel_time(void)
16{
17 struct timespec64 now = current_kernel_time64();
18
19 return timespec64_to_timespec(now);
20}
21
22#if BITS_PER_LONG == 64
23/**
24 * Deprecated. Use do_settimeofday64().
25 */
26static inline int do_settimeofday(const struct timespec *ts)
27{
28 return do_settimeofday64(ts);
29}
30
31static inline int __getnstimeofday(struct timespec *ts)
32{
33 return __getnstimeofday64(ts);
34}
35
36static inline void getnstimeofday(struct timespec *ts)
37{
38 getnstimeofday64(ts);
39}
40
41static inline void ktime_get_ts(struct timespec *ts)
42{
43 ktime_get_ts64(ts);
44}
45
46static inline void ktime_get_real_ts(struct timespec *ts)
47{
48 getnstimeofday64(ts);
49}
50
51static inline void getrawmonotonic(struct timespec *ts)
52{
53 getrawmonotonic64(ts);
54}
55
56static inline struct timespec get_monotonic_coarse(void)
57{
58 return get_monotonic_coarse64();
59}
60
61static inline void getboottime(struct timespec *ts)
62{
63 return getboottime64(ts);
64}
65#else
66/**
67 * Deprecated. Use do_settimeofday64().
68 */
69static inline int do_settimeofday(const struct timespec *ts)
70{
71 struct timespec64 ts64;
72
73 ts64 = timespec_to_timespec64(*ts);
74 return do_settimeofday64(&ts64);
75}
76
77static inline int __getnstimeofday(struct timespec *ts)
78{
79 struct timespec64 ts64;
80 int ret = __getnstimeofday64(&ts64);
81
82 *ts = timespec64_to_timespec(ts64);
83 return ret;
84}
85
86static inline void getnstimeofday(struct timespec *ts)
87{
88 struct timespec64 ts64;
89
90 getnstimeofday64(&ts64);
91 *ts = timespec64_to_timespec(ts64);
92}
93
94static inline void ktime_get_ts(struct timespec *ts)
95{
96 struct timespec64 ts64;
97
98 ktime_get_ts64(&ts64);
99 *ts = timespec64_to_timespec(ts64);
100}
101
102static inline void ktime_get_real_ts(struct timespec *ts)
103{
104 struct timespec64 ts64;
105
106 getnstimeofday64(&ts64);
107 *ts = timespec64_to_timespec(ts64);
108}
109
110static inline void getrawmonotonic(struct timespec *ts)
111{
112 struct timespec64 ts64;
113
114 getrawmonotonic64(&ts64);
115 *ts = timespec64_to_timespec(ts64);
116}
117
118static inline struct timespec get_monotonic_coarse(void)
119{
120 return timespec64_to_timespec(get_monotonic_coarse64());
121}
122
123static inline void getboottime(struct timespec *ts)
124{
125 struct timespec64 ts64;
126
127 getboottime64(&ts64);
128 *ts = timespec64_to_timespec(ts64);
129}
130#endif
131
132/*
133 * Timespec interfaces utilizing the ktime based ones
134 */
135static inline void get_monotonic_boottime(struct timespec *ts)
136{
137 *ts = ktime_to_timespec(ktime_get_boottime());
138}
139
140static inline void timekeeping_clocktai(struct timespec *ts)
141{
142 *ts = ktime_to_timespec(ktime_get_clocktai());
143}
144
145/*
146 * Persistent clock related interfaces
147 */
148extern void read_persistent_clock(struct timespec *ts);
149extern int update_persistent_clock(struct timespec now);
150
151#endif