Skip to content

Commit fb7fcc9

Browse files
arndbKAGA-KOKO
authored andcommitted
timekeeping: Standardize on ktime_get_*() naming
The current_kernel_time64, get_monotonic_coarse64, getrawmonotonic64, get_monotonic_boottime64 and timekeeping_clocktai64 interfaces have rather inconsistent naming, and they differ in the calling conventions by passing the output either by reference or as a return value. Rename them to ktime_get_coarse_real_ts64, ktime_get_coarse_ts64, ktime_get_raw_ts64, ktime_get_boottime_ts64 and ktime_get_clocktai_ts64 respectively, and provide the interfaces with macros or inline functions as needed. 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-4-arnd@arndb.de
1 parent edca71f commit fb7fcc9

File tree

3 files changed

+51
-29
lines changed

3 files changed

+51
-29
lines changed

include/linux/timekeeping.h

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ extern void xtime_update(unsigned long ticks);
1919
extern int do_settimeofday64(const struct timespec64 *ts);
2020
extern int do_sys_settimeofday64(const struct timespec64 *tv,
2121
const struct timezone *tz);
22-
/*
23-
* Kernel time accessors
24-
*/
25-
struct timespec64 current_kernel_time64(void);
2622

2723
/*
2824
* timespec64 based interfaces
2925
*/
30-
struct timespec64 get_monotonic_coarse64(void);
31-
extern void getrawmonotonic64(struct timespec64 *ts);
26+
extern void ktime_get_raw_ts64(struct timespec64 *ts);
3227
extern void ktime_get_ts64(struct timespec64 *ts);
3328
extern void ktime_get_real_ts64(struct timespec64 *tv);
29+
extern void ktime_get_coarse_ts64(struct timespec64 *ts);
30+
extern void ktime_get_coarse_real_ts64(struct timespec64 *ts);
31+
32+
void getboottime64(struct timespec64 *ts);
33+
34+
/*
35+
* time64_t base interfaces
36+
*/
3437
extern time64_t ktime_get_seconds(void);
3538
extern time64_t __ktime_get_real_seconds(void);
3639
extern time64_t ktime_get_real_seconds(void);
3740

38-
extern void getboottime64(struct timespec64 *ts);
39-
40-
4141
/*
4242
* ktime_t based interfaces
4343
*/
@@ -123,12 +123,12 @@ extern u64 ktime_get_real_fast_ns(void);
123123
/*
124124
* timespec64 interfaces utilizing the ktime based ones
125125
*/
126-
static inline void get_monotonic_boottime64(struct timespec64 *ts)
126+
static inline void ktime_get_boottime_ts64(struct timespec64 *ts)
127127
{
128128
*ts = ktime_to_timespec64(ktime_get_boottime());
129129
}
130130

131-
static inline void timekeeping_clocktai64(struct timespec64 *ts)
131+
static inline void ktime_get_clocktai_ts64(struct timespec64 *ts)
132132
{
133133
*ts = ktime_to_timespec64(ktime_get_clocktai());
134134
}
@@ -212,5 +212,26 @@ extern int update_persistent_clock64(struct timespec64 now);
212212
* deprecated aliases, don't use in new code
213213
*/
214214
#define getnstimeofday64(ts) ktime_get_real_ts64(ts)
215+
#define get_monotonic_boottime64(ts) ktime_get_boottime_ts64(ts)
216+
#define getrawmonotonic64(ts) ktime_get_raw_ts64(ts)
217+
#define timekeeping_clocktai64(ts) ktime_get_clocktai_ts64(ts)
218+
219+
static inline struct timespec64 current_kernel_time64(void)
220+
{
221+
struct timespec64 ts;
222+
223+
ktime_get_coarse_real_ts64(&ts);
224+
225+
return ts;
226+
}
227+
228+
static inline struct timespec64 get_monotonic_coarse64(void)
229+
{
230+
struct timespec64 ts;
231+
232+
ktime_get_coarse_ts64(&ts);
233+
234+
return ts;
235+
}
215236

216237
#endif

include/linux/timekeeping32.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ unsigned long get_seconds(void);
1111

1212
static inline struct timespec current_kernel_time(void)
1313
{
14-
struct timespec64 now = current_kernel_time64();
14+
struct timespec64 ts64;
15+
16+
ktime_get_coarse_real_ts64(&ts64);
1517

16-
return timespec64_to_timespec(now);
18+
return timespec64_to_timespec(ts64);
1719
}
1820

1921
/**
@@ -55,13 +57,17 @@ static inline void getrawmonotonic(struct timespec *ts)
5557
{
5658
struct timespec64 ts64;
5759

58-
getrawmonotonic64(&ts64);
60+
ktime_get_raw_ts64(&ts64);
5961
*ts = timespec64_to_timespec(ts64);
6062
}
6163

6264
static inline struct timespec get_monotonic_coarse(void)
6365
{
64-
return timespec64_to_timespec(get_monotonic_coarse64());
66+
struct timespec64 ts64;
67+
68+
ktime_get_coarse_ts64(&ts64);
69+
70+
return timespec64_to_timespec(ts64);
6571
}
6672

6773
static inline void getboottime(struct timespec *ts)

kernel/time/timekeeping.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,12 +1391,12 @@ int timekeeping_notify(struct clocksource *clock)
13911391
}
13921392

13931393
/**
1394-
* getrawmonotonic64 - Returns the raw monotonic time in a timespec
1394+
* ktime_get_raw_ts64 - Returns the raw monotonic time in a timespec
13951395
* @ts: pointer to the timespec64 to be set
13961396
*
13971397
* Returns the raw monotonic time (completely un-modified by ntp)
13981398
*/
1399-
void getrawmonotonic64(struct timespec64 *ts)
1399+
void ktime_get_raw_ts64(struct timespec64 *ts)
14001400
{
14011401
struct timekeeper *tk = &tk_core.timekeeper;
14021402
unsigned long seq;
@@ -1412,7 +1412,7 @@ void getrawmonotonic64(struct timespec64 *ts)
14121412
ts->tv_nsec = 0;
14131413
timespec64_add_ns(ts, nsecs);
14141414
}
1415-
EXPORT_SYMBOL(getrawmonotonic64);
1415+
EXPORT_SYMBOL(ktime_get_raw_ts64);
14161416

14171417

14181418
/**
@@ -2114,23 +2114,20 @@ unsigned long get_seconds(void)
21142114
}
21152115
EXPORT_SYMBOL(get_seconds);
21162116

2117-
struct timespec64 current_kernel_time64(void)
2117+
void ktime_get_coarse_real_ts64(struct timespec64 *ts)
21182118
{
21192119
struct timekeeper *tk = &tk_core.timekeeper;
2120-
struct timespec64 now;
21212120
unsigned long seq;
21222121

21232122
do {
21242123
seq = read_seqcount_begin(&tk_core.seq);
21252124

2126-
now = tk_xtime(tk);
2125+
*ts = tk_xtime(tk);
21272126
} while (read_seqcount_retry(&tk_core.seq, seq));
2128-
2129-
return now;
21302127
}
2131-
EXPORT_SYMBOL(current_kernel_time64);
2128+
EXPORT_SYMBOL(ktime_get_coarse_real_ts64);
21322129

2133-
struct timespec64 get_monotonic_coarse64(void)
2130+
void ktime_get_coarse_ts64(struct timespec64 *ts)
21342131
{
21352132
struct timekeeper *tk = &tk_core.timekeeper;
21362133
struct timespec64 now, mono;
@@ -2143,12 +2140,10 @@ struct timespec64 get_monotonic_coarse64(void)
21432140
mono = tk->wall_to_monotonic;
21442141
} while (read_seqcount_retry(&tk_core.seq, seq));
21452142

2146-
set_normalized_timespec64(&now, now.tv_sec + mono.tv_sec,
2143+
set_normalized_timespec64(ts, now.tv_sec + mono.tv_sec,
21472144
now.tv_nsec + mono.tv_nsec);
2148-
2149-
return now;
21502145
}
2151-
EXPORT_SYMBOL(get_monotonic_coarse64);
2146+
EXPORT_SYMBOL(ktime_get_coarse_ts64);
21522147

21532148
/*
21542149
* Must hold jiffies_lock

0 commit comments

Comments
 (0)