aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-04-27 09:40:13 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-05-19 07:57:32 -0400
commitedca71fecb77e2697337d192cbfe96f513407761 (patch)
treecfaf4a1c3200f1dc396e28076d17229930e5fece
parent4f0fad9a603aee91a374e8411c23953894a77479 (diff)
timekeeping: Clean up ktime_get_real_ts64
In a move to make ktime_get_*() the preferred driver interface into the timekeeping code, sanitizes ktime_get_real_ts64() to be a proper exported symbol rather than an alias for getnstimeofday64(). The internal __getnstimeofday64() is no longer used, so remove that and merge it into ktime_get_real_ts64(). Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Stephen Boyd <sboyd@kernel.org> Cc: y2038@lists.linaro.org Cc: John Stultz <john.stultz@linaro.org> Link: https://lkml.kernel.org/r/20180427134016.2525989-3-arnd@arndb.de
-rw-r--r--include/linux/timekeeping.h8
-rw-r--r--include/linux/timekeeping32.h13
-rw-r--r--kernel/time/timekeeping.c31
3 files changed, 13 insertions, 39 deletions
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 588a0e4b1ab9..415dae6bf1f5 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -30,15 +30,13 @@ struct timespec64 current_kernel_time64(void);
30struct timespec64 get_monotonic_coarse64(void); 30struct timespec64 get_monotonic_coarse64(void);
31extern void getrawmonotonic64(struct timespec64 *ts); 31extern void getrawmonotonic64(struct timespec64 *ts);
32extern void ktime_get_ts64(struct timespec64 *ts); 32extern void ktime_get_ts64(struct timespec64 *ts);
33extern void ktime_get_real_ts64(struct timespec64 *tv);
33extern time64_t ktime_get_seconds(void); 34extern time64_t ktime_get_seconds(void);
34extern time64_t __ktime_get_real_seconds(void); 35extern time64_t __ktime_get_real_seconds(void);
35extern time64_t ktime_get_real_seconds(void); 36extern time64_t ktime_get_real_seconds(void);
36 37
37extern int __getnstimeofday64(struct timespec64 *tv);
38extern void getnstimeofday64(struct timespec64 *tv);
39extern void getboottime64(struct timespec64 *ts); 38extern void getboottime64(struct timespec64 *ts);
40 39
41#define ktime_get_real_ts64(ts) getnstimeofday64(ts)
42 40
43/* 41/*
44 * ktime_t based interfaces 42 * ktime_t based interfaces
@@ -210,5 +208,9 @@ extern void read_persistent_clock64(struct timespec64 *ts);
210extern void read_boot_clock64(struct timespec64 *ts); 208extern void read_boot_clock64(struct timespec64 *ts);
211extern int update_persistent_clock64(struct timespec64 now); 209extern int update_persistent_clock64(struct timespec64 now);
212 210
211/*
212 * deprecated aliases, don't use in new code
213 */
214#define getnstimeofday64(ts) ktime_get_real_ts64(ts)
213 215
214#endif 216#endif
diff --git a/include/linux/timekeeping32.h b/include/linux/timekeeping32.h
index 4ea45d0df1d4..5abff52d07fd 100644
--- a/include/linux/timekeeping32.h
+++ b/include/linux/timekeeping32.h
@@ -27,20 +27,11 @@ static inline int do_settimeofday(const struct timespec *ts)
27 return do_settimeofday64(&ts64); 27 return do_settimeofday64(&ts64);
28} 28}
29 29
30static inline int __getnstimeofday(struct timespec *ts)
31{
32 struct timespec64 ts64;
33 int ret = __getnstimeofday64(&ts64);
34
35 *ts = timespec64_to_timespec(ts64);
36 return ret;
37}
38
39static inline void getnstimeofday(struct timespec *ts) 30static inline void getnstimeofday(struct timespec *ts)
40{ 31{
41 struct timespec64 ts64; 32 struct timespec64 ts64;
42 33
43 getnstimeofday64(&ts64); 34 ktime_get_real_ts64(&ts64);
44 *ts = timespec64_to_timespec(ts64); 35 *ts = timespec64_to_timespec(ts64);
45} 36}
46 37
@@ -56,7 +47,7 @@ static inline void ktime_get_real_ts(struct timespec *ts)
56{ 47{
57 struct timespec64 ts64; 48 struct timespec64 ts64;
58 49
59 getnstimeofday64(&ts64); 50 ktime_get_real_ts64(&ts64);
60 *ts = timespec64_to_timespec(ts64); 51 *ts = timespec64_to_timespec(ts64);
61} 52}
62 53
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 49cbceef5deb..7bbc7a6e6095 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -705,18 +705,19 @@ static void timekeeping_forward_now(struct timekeeper *tk)
705} 705}
706 706
707/** 707/**
708 * __getnstimeofday64 - Returns the time of day in a timespec64. 708 * ktime_get_real_ts64 - Returns the time of day in a timespec64.
709 * @ts: pointer to the timespec to be set 709 * @ts: pointer to the timespec to be set
710 * 710 *
711 * Updates the time of day in the timespec. 711 * Returns the time of day in a timespec64 (WARN if suspended).
712 * Returns 0 on success, or -ve when suspended (timespec will be undefined).
713 */ 712 */
714int __getnstimeofday64(struct timespec64 *ts) 713void ktime_get_real_ts64(struct timespec64 *ts)
715{ 714{
716 struct timekeeper *tk = &tk_core.timekeeper; 715 struct timekeeper *tk = &tk_core.timekeeper;
717 unsigned long seq; 716 unsigned long seq;
718 u64 nsecs; 717 u64 nsecs;
719 718
719 WARN_ON(timekeeping_suspended);
720
720 do { 721 do {
721 seq = read_seqcount_begin(&tk_core.seq); 722 seq = read_seqcount_begin(&tk_core.seq);
722 723
@@ -727,28 +728,8 @@ int __getnstimeofday64(struct timespec64 *ts)
727 728
728 ts->tv_nsec = 0; 729 ts->tv_nsec = 0;
729 timespec64_add_ns(ts, nsecs); 730 timespec64_add_ns(ts, nsecs);
730
731 /*
732 * Do not bail out early, in case there were callers still using
733 * the value, even in the face of the WARN_ON.
734 */
735 if (unlikely(timekeeping_suspended))
736 return -EAGAIN;
737 return 0;
738}
739EXPORT_SYMBOL(__getnstimeofday64);
740
741/**
742 * getnstimeofday64 - Returns the time of day in a timespec64.
743 * @ts: pointer to the timespec64 to be set
744 *
745 * Returns the time of day in a timespec64 (WARN if suspended).
746 */
747void getnstimeofday64(struct timespec64 *ts)
748{
749 WARN_ON(__getnstimeofday64(ts));
750} 731}
751EXPORT_SYMBOL(getnstimeofday64); 732EXPORT_SYMBOL(ktime_get_real_ts64);
752 733
753ktime_t ktime_get(void) 734ktime_t ktime_get(void)
754{ 735{