Commit 48f18fd6 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by John Stultz

timekeeping: Use ktime_get_boottime() for get_monotonic_boottime()

get_monotonic_boottime() is not used in fast pathes, so the extra
timespec conversion is not problematic.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent 250fade8
...@@ -27,7 +27,6 @@ struct timespec __current_kernel_time(void); ...@@ -27,7 +27,6 @@ struct timespec __current_kernel_time(void);
*/ */
struct timespec get_monotonic_coarse(void); struct timespec get_monotonic_coarse(void);
extern void getrawmonotonic(struct timespec *ts); extern void getrawmonotonic(struct timespec *ts);
extern void get_monotonic_boottime(struct timespec *ts);
extern void ktime_get_ts64(struct timespec64 *ts); extern void ktime_get_ts64(struct timespec64 *ts);
extern int __getnstimeofday64(struct timespec64 *tv); extern int __getnstimeofday64(struct timespec64 *tv);
...@@ -159,6 +158,14 @@ static inline u64 ktime_get_boot_ns(void) ...@@ -159,6 +158,14 @@ static inline u64 ktime_get_boot_ns(void)
return ktime_to_ns(ktime_get_boottime()); return ktime_to_ns(ktime_get_boottime());
} }
/*
* Timespec interfaces utilizing the ktime based ones
*/
static inline void get_monotonic_boottime(struct timespec *ts)
{
*ts = ktime_to_timespec(ktime_get_boottime());
}
/* /*
* RTC specific * RTC specific
*/ */
......
...@@ -1536,40 +1536,6 @@ void getboottime(struct timespec *ts) ...@@ -1536,40 +1536,6 @@ void getboottime(struct timespec *ts)
} }
EXPORT_SYMBOL_GPL(getboottime); EXPORT_SYMBOL_GPL(getboottime);
/**
* get_monotonic_boottime - Returns monotonic time since boot
* @ts: pointer to the timespec to be set
*
* Returns the monotonic time since boot in a timespec.
*
* This is similar to CLOCK_MONTONIC/ktime_get_ts, but also
* includes the time spent in suspend.
*/
void get_monotonic_boottime(struct timespec *ts)
{
struct timekeeper *tk = &tk_core.timekeeper;
struct timespec64 tomono, sleep, ret;
s64 nsec;
unsigned int seq;
WARN_ON(timekeeping_suspended);
do {
seq = read_seqcount_begin(&tk_core.seq);
ret.tv_sec = tk->xtime_sec;
nsec = timekeeping_get_ns(tk);
tomono = tk->wall_to_monotonic;
sleep = tk->total_sleep_time;
} while (read_seqcount_retry(&tk_core.seq, seq));
ret.tv_sec += tomono.tv_sec + sleep.tv_sec;
ret.tv_nsec = 0;
timespec64_add_ns(&ret, nsec + tomono.tv_nsec + sleep.tv_nsec);
*ts = timespec64_to_timespec(ret);
}
EXPORT_SYMBOL_GPL(get_monotonic_boottime);
unsigned long get_seconds(void) unsigned long get_seconds(void)
{ {
struct timekeeper *tk = &tk_core.timekeeper; struct timekeeper *tk = &tk_core.timekeeper;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment