summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2015-09-28 16:21:29 -0400
committerJohn Stultz <john.stultz@linaro.org>2015-10-01 12:59:01 -0400
commit071eee45b1650d53d21c636d344bdcebd4577ed2 (patch)
tree3e22cf4327f43092c26e2eb11236379ec7320f2f
parent7ec88e4be461590b5a3817460c34603f76d9b3ae (diff)
ntp/pps: replace getnstime_raw_and_real with 64-bit version
There is exactly one caller of getnstime_raw_and_real in the kernel, which is the pps_get_ts function. This changes the caller and the implementation to work on timespec64 types rather than timespec, to avoid the time_t overflow on 32-bit architectures. For consistency with the other new functions (ktime_get_seconds, ktime_get_real_*, ...), I'm renaming the function to ktime_get_raw_and_real_ts64. We still need to convert from the internal 64-bit type to 32 bit types in the caller, but this conversion is now pushed out from getnstime_raw_and_real to pps_get_ts. A follow-up patch changes the remaining pps code to completely avoid the conversion. Acked-by: Richard Cochran <richardcochran@gmail.com> Acked-by: David S. Miller <davem@davemloft.net> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
-rw-r--r--include/linux/pps_kernel.h7
-rw-r--r--include/linux/timekeeping.h4
-rw-r--r--kernel/time/timekeeping.c12
3 files changed, 14 insertions, 9 deletions
diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h
index 1d2cd21242e8..b2fbd62ab18d 100644
--- a/include/linux/pps_kernel.h
+++ b/include/linux/pps_kernel.h
@@ -115,7 +115,12 @@ static inline void timespec_to_pps_ktime(struct pps_ktime *kt,
115 115
116static inline void pps_get_ts(struct pps_event_time *ts) 116static inline void pps_get_ts(struct pps_event_time *ts)
117{ 117{
118 getnstime_raw_and_real(&ts->ts_raw, &ts->ts_real); 118 struct timespec64 raw, real;
119
120 ktime_get_raw_and_real_ts64(&raw, &real);
121
122 ts->ts_raw = timespec64_to_timespec(raw);
123 ts->ts_real = timespec64_to_timespec(real);
119} 124}
120 125
121#else /* CONFIG_NTP_PPS */ 126#else /* CONFIG_NTP_PPS */
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index ba0ae09cbb21..ec89d846324c 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -263,8 +263,8 @@ extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
263/* 263/*
264 * PPS accessor 264 * PPS accessor
265 */ 265 */
266extern void getnstime_raw_and_real(struct timespec *ts_raw, 266extern void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw,
267 struct timespec *ts_real); 267 struct timespec64 *ts_real);
268 268
269/* 269/*
270 * Persistent clock related interfaces 270 * Persistent clock related interfaces
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 177188b11a2e..274ed5e88456 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -849,7 +849,7 @@ EXPORT_SYMBOL_GPL(ktime_get_real_seconds);
849#ifdef CONFIG_NTP_PPS 849#ifdef CONFIG_NTP_PPS
850 850
851/** 851/**
852 * getnstime_raw_and_real - get day and raw monotonic time in timespec format 852 * ktime_get_raw_and_real_ts64 - get day and raw monotonic time in timespec format
853 * @ts_raw: pointer to the timespec to be set to raw monotonic time 853 * @ts_raw: pointer to the timespec to be set to raw monotonic time
854 * @ts_real: pointer to the timespec to be set to the time of day 854 * @ts_real: pointer to the timespec to be set to the time of day
855 * 855 *
@@ -857,7 +857,7 @@ EXPORT_SYMBOL_GPL(ktime_get_real_seconds);
857 * same time atomically and stores the resulting timestamps in timespec 857 * same time atomically and stores the resulting timestamps in timespec
858 * format. 858 * format.
859 */ 859 */
860void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real) 860void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw, struct timespec64 *ts_real)
861{ 861{
862 struct timekeeper *tk = &tk_core.timekeeper; 862 struct timekeeper *tk = &tk_core.timekeeper;
863 unsigned long seq; 863 unsigned long seq;
@@ -868,7 +868,7 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
868 do { 868 do {
869 seq = read_seqcount_begin(&tk_core.seq); 869 seq = read_seqcount_begin(&tk_core.seq);
870 870
871 *ts_raw = timespec64_to_timespec(tk->raw_time); 871 *ts_raw = tk->raw_time;
872 ts_real->tv_sec = tk->xtime_sec; 872 ts_real->tv_sec = tk->xtime_sec;
873 ts_real->tv_nsec = 0; 873 ts_real->tv_nsec = 0;
874 874
@@ -877,10 +877,10 @@ void getnstime_raw_and_real(struct timespec *ts_raw, struct timespec *ts_real)
877 877
878 } while (read_seqcount_retry(&tk_core.seq, seq)); 878 } while (read_seqcount_retry(&tk_core.seq, seq));
879 879
880 timespec_add_ns(ts_raw, nsecs_raw); 880 timespec64_add_ns(ts_raw, nsecs_raw);
881 timespec_add_ns(ts_real, nsecs_real); 881 timespec64_add_ns(ts_real, nsecs_real);
882} 882}
883EXPORT_SYMBOL(getnstime_raw_and_real); 883EXPORT_SYMBOL(ktime_get_raw_and_real_ts64);
884 884
885#endif /* CONFIG_NTP_PPS */ 885#endif /* CONFIG_NTP_PPS */
886 886