diff options
author | John Stultz <john.stultz@linaro.org> | 2012-05-03 19:43:40 (GMT) |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2013-03-22 23:19:59 (GMT) |
commit | 1ff3c9677bff7e468e0c487d0ffefe4e901d33f4 (patch) | |
tree | 202cef5857654e15eb471c2216f37f995f1c6e2f /kernel/time | |
parent | cc244ddae6d4c6902ac9d7d64023534f8c44a7eb (diff) | |
download | linux-1ff3c9677bff7e468e0c487d0ffefe4e901d33f4.tar.xz |
timekeeping: Add CLOCK_TAI clockid
This add a CLOCK_TAI clockid and the needed accessors.
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
-rw-r--r-- | kernel/time/timekeeping.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 937098a..8a84275 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -379,6 +379,36 @@ void ktime_get_ts(struct timespec *ts) } EXPORT_SYMBOL_GPL(ktime_get_ts); + +/** + * timekeeping_clocktai - Returns the TAI time of day in a timespec + * @ts: pointer to the timespec to be set + * + * Returns the time of day in a timespec. + */ +void timekeeping_clocktai(struct timespec *ts) +{ + struct timekeeper *tk = &timekeeper; + unsigned long seq; + u64 nsecs; + + WARN_ON(timekeeping_suspended); + + do { + seq = read_seqbegin(&tk->lock); + + ts->tv_sec = tk->xtime_sec + tk->tai_offset; + nsecs = timekeeping_get_ns(tk); + + } while (read_seqretry(&tk->lock, seq)); + + ts->tv_nsec = 0; + timespec_add_ns(ts, nsecs); + +} +EXPORT_SYMBOL(timekeeping_clocktai); + + #ifdef CONFIG_NTP_PPS /** |