Skip to content

Commit edca71f

Browse files
arndbKAGA-KOKO
authored andcommitted
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
1 parent 4f0fad9 commit edca71f

File tree

3 files changed

+13
-39
lines changed

3 files changed

+13
-39
lines changed

include/linux/timekeeping.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ struct timespec64 current_kernel_time64(void);
3030
struct timespec64 get_monotonic_coarse64(void);
3131
extern void getrawmonotonic64(struct timespec64 *ts);
3232
extern void ktime_get_ts64(struct timespec64 *ts);
33+
extern void ktime_get_real_ts64(struct timespec64 *tv);
3334
extern time64_t ktime_get_seconds(void);
3435
extern time64_t __ktime_get_real_seconds(void);
3536
extern time64_t ktime_get_real_seconds(void);
3637

37-
extern int __getnstimeofday64(struct timespec64 *tv);
38-
extern void getnstimeofday64(struct timespec64 *tv);
3938
extern void getboottime64(struct timespec64 *ts);
4039

41-
#define ktime_get_real_ts64(ts) getnstimeofday64(ts)
4240

4341
/*
4442
* ktime_t based interfaces
@@ -210,5 +208,9 @@ extern void read_persistent_clock64(struct timespec64 *ts);
210208
extern void read_boot_clock64(struct timespec64 *ts);
211209
extern int update_persistent_clock64(struct timespec64 now);
212210

211+
/*
212+
* deprecated aliases, don't use in new code
213+
*/
214+
#define getnstimeofday64(ts) ktime_get_real_ts64(ts)
213215

214216
#endif

include/linux/timekeeping32.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,11 @@ static inline int do_settimeofday(const struct timespec *ts)
2727
return do_settimeofday64(&ts64);
2828
}
2929

30-
static 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-
3930
static inline void getnstimeofday(struct timespec *ts)
4031
{
4132
struct timespec64 ts64;
4233

43-
getnstimeofday64(&ts64);
34+
ktime_get_real_ts64(&ts64);
4435
*ts = timespec64_to_timespec(ts64);
4536
}
4637

@@ -56,7 +47,7 @@ static inline void ktime_get_real_ts(struct timespec *ts)
5647
{
5748
struct timespec64 ts64;
5849

59-
getnstimeofday64(&ts64);
50+
ktime_get_real_ts64(&ts64);
6051
*ts = timespec64_to_timespec(ts64);
6152
}
6253

kernel/time/timekeeping.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -705,18 +705,19 @@ static void timekeeping_forward_now(struct timekeeper *tk)
705705
}
706706

707707
/**
708-
* __getnstimeofday64 - Returns the time of day in a timespec64.
708+
* ktime_get_real_ts64 - Returns the time of day in a timespec64.
709709
* @ts: pointer to the timespec to be set
710710
*
711-
* Updates the time of day in the timespec.
712-
* Returns 0 on success, or -ve when suspended (timespec will be undefined).
711+
* Returns the time of day in a timespec64 (WARN if suspended).
713712
*/
714-
int __getnstimeofday64(struct timespec64 *ts)
713+
void ktime_get_real_ts64(struct timespec64 *ts)
715714
{
716715
struct timekeeper *tk = &tk_core.timekeeper;
717716
unsigned long seq;
718717
u64 nsecs;
719718

719+
WARN_ON(timekeeping_suspended);
720+
720721
do {
721722
seq = read_seqcount_begin(&tk_core.seq);
722723

@@ -727,28 +728,8 @@ int __getnstimeofday64(struct timespec64 *ts)
727728

728729
ts->tv_nsec = 0;
729730
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-
}
739-
EXPORT_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-
*/
747-
void getnstimeofday64(struct timespec64 *ts)
748-
{
749-
WARN_ON(__getnstimeofday64(ts));
750731
}
751-
EXPORT_SYMBOL(getnstimeofday64);
732+
EXPORT_SYMBOL(ktime_get_real_ts64);
752733

753734
ktime_t ktime_get(void)
754735
{

0 commit comments

Comments
 (0)