diff options
author | John Stultz <john.stultz@linaro.org> | 2012-05-03 15:30:07 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2013-03-22 19:19:58 -0400 |
commit | cc244ddae6d4c6902ac9d7d64023534f8c44a7eb (patch) | |
tree | 9f9e26d214bd0113d8722c0a683e003cbc1bf165 /kernel/time/timekeeping.c | |
parent | e445cf1c4257cc0238d72e4129eb4739f46fd3de (diff) |
timekeeping: Move TAI managment into timekeeping core from ntp
Currently NTP manages the TAI offset. Since there's plans for a
CLOCK_TAI clockid, push the TAI management into the timekeeping
core.
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/timekeeping.c')
-rw-r--r-- | kernel/time/timekeeping.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 0355f125d585..937098aab498 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -513,6 +513,48 @@ error: /* even if we error out, we forwarded the time, so call update */ | |||
513 | } | 513 | } |
514 | EXPORT_SYMBOL(timekeeping_inject_offset); | 514 | EXPORT_SYMBOL(timekeeping_inject_offset); |
515 | 515 | ||
516 | |||
517 | /** | ||
518 | * timekeeping_get_tai_offset - Returns current TAI offset from UTC | ||
519 | * | ||
520 | */ | ||
521 | s32 timekeeping_get_tai_offset(void) | ||
522 | { | ||
523 | struct timekeeper *tk = &timekeeper; | ||
524 | unsigned int seq; | ||
525 | s32 ret; | ||
526 | |||
527 | do { | ||
528 | seq = read_seqbegin(&tk->lock); | ||
529 | ret = tk->tai_offset; | ||
530 | } while (read_seqretry(&tk->lock, seq)); | ||
531 | |||
532 | return ret; | ||
533 | } | ||
534 | |||
535 | /** | ||
536 | * __timekeeping_set_tai_offset - Lock free worker function | ||
537 | * | ||
538 | */ | ||
539 | void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) | ||
540 | { | ||
541 | tk->tai_offset = tai_offset; | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * timekeeping_set_tai_offset - Sets the current TAI offset from UTC | ||
546 | * | ||
547 | */ | ||
548 | void timekeeping_set_tai_offset(s32 tai_offset) | ||
549 | { | ||
550 | struct timekeeper *tk = &timekeeper; | ||
551 | unsigned long flags; | ||
552 | |||
553 | write_seqlock_irqsave(&tk->lock, flags); | ||
554 | __timekeeping_set_tai_offset(tk, tai_offset); | ||
555 | write_sequnlock_irqrestore(&tk->lock, flags); | ||
556 | } | ||
557 | |||
516 | /** | 558 | /** |
517 | * change_clocksource - Swaps clocksources if a new one is available | 559 | * change_clocksource - Swaps clocksources if a new one is available |
518 | * | 560 | * |
@@ -1143,6 +1185,8 @@ static inline void accumulate_nsecs_to_secs(struct timekeeper *tk) | |||
1143 | tk_set_wall_to_mono(tk, | 1185 | tk_set_wall_to_mono(tk, |
1144 | timespec_sub(tk->wall_to_monotonic, ts)); | 1186 | timespec_sub(tk->wall_to_monotonic, ts)); |
1145 | 1187 | ||
1188 | __timekeeping_set_tai_offset(tk, tk->tai_offset - leap); | ||
1189 | |||
1146 | clock_was_set_delayed(); | 1190 | clock_was_set_delayed(); |
1147 | } | 1191 | } |
1148 | } | 1192 | } |