aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJohn Stultz <john.stultz@linaro.org>2012-05-03 15:43:40 -0400
committerJohn Stultz <john.stultz@linaro.org>2013-03-22 19:19:59 -0400
commit1ff3c9677bff7e468e0c487d0ffefe4e901d33f4 (patch)
tree202cef5857654e15eb471c2216f37f995f1c6e2f /kernel
parentcc244ddae6d4c6902ac9d7d64023534f8c44a7eb (diff)
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')
-rw-r--r--kernel/posix-timers.c10
-rw-r--r--kernel/time/timekeeping.c30
2 files changed, 40 insertions, 0 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 6edbb2c55c22..fbfc5f1b7710 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -221,6 +221,11 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
221 return 0; 221 return 0;
222} 222}
223 223
224static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
225{
226 timekeeping_clocktai(tp);
227 return 0;
228}
224 229
225/* 230/*
226 * Initialize everything, well, just everything in Posix clocks/timers ;) 231 * Initialize everything, well, just everything in Posix clocks/timers ;)
@@ -261,6 +266,10 @@ static __init int init_posix_timers(void)
261 .clock_getres = posix_get_coarse_res, 266 .clock_getres = posix_get_coarse_res,
262 .clock_get = posix_get_monotonic_coarse, 267 .clock_get = posix_get_monotonic_coarse,
263 }; 268 };
269 struct k_clock clock_tai = {
270 .clock_getres = hrtimer_get_res,
271 .clock_get = posix_get_tai,
272 };
264 struct k_clock clock_boottime = { 273 struct k_clock clock_boottime = {
265 .clock_getres = hrtimer_get_res, 274 .clock_getres = hrtimer_get_res,
266 .clock_get = posix_get_boottime, 275 .clock_get = posix_get_boottime,
@@ -278,6 +287,7 @@ static __init int init_posix_timers(void)
278 posix_timers_register_clock(CLOCK_REALTIME_COARSE, &clock_realtime_coarse); 287 posix_timers_register_clock(CLOCK_REALTIME_COARSE, &clock_realtime_coarse);
279 posix_timers_register_clock(CLOCK_MONOTONIC_COARSE, &clock_monotonic_coarse); 288 posix_timers_register_clock(CLOCK_MONOTONIC_COARSE, &clock_monotonic_coarse);
280 posix_timers_register_clock(CLOCK_BOOTTIME, &clock_boottime); 289 posix_timers_register_clock(CLOCK_BOOTTIME, &clock_boottime);
290 posix_timers_register_clock(CLOCK_TAI, &clock_tai);
281 291
282 posix_timers_cache = kmem_cache_create("posix_timers_cache", 292 posix_timers_cache = kmem_cache_create("posix_timers_cache",
283 sizeof (struct k_itimer), 0, SLAB_PANIC, 293 sizeof (struct k_itimer), 0, SLAB_PANIC,
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 937098aab498..8a842756572d 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -379,6 +379,36 @@ void ktime_get_ts(struct timespec *ts)
379} 379}
380EXPORT_SYMBOL_GPL(ktime_get_ts); 380EXPORT_SYMBOL_GPL(ktime_get_ts);
381 381
382
383/**
384 * timekeeping_clocktai - Returns the TAI time of day in a timespec
385 * @ts: pointer to the timespec to be set
386 *
387 * Returns the time of day in a timespec.
388 */
389void timekeeping_clocktai(struct timespec *ts)
390{
391 struct timekeeper *tk = &timekeeper;
392 unsigned long seq;
393 u64 nsecs;
394
395 WARN_ON(timekeeping_suspended);
396
397 do {
398 seq = read_seqbegin(&tk->lock);
399
400 ts->tv_sec = tk->xtime_sec + tk->tai_offset;
401 nsecs = timekeeping_get_ns(tk);
402
403 } while (read_seqretry(&tk->lock, seq));
404
405 ts->tv_nsec = 0;
406 timespec_add_ns(ts, nsecs);
407
408}
409EXPORT_SYMBOL(timekeeping_clocktai);
410
411
382#ifdef CONFIG_NTP_PPS 412#ifdef CONFIG_NTP_PPS
383 413
384/** 414/**