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/ntp.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/ntp.c')
-rw-r--r-- | kernel/time/ntp.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 072bb066bb7d..59e2749be0fa 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -53,9 +53,6 @@ static int time_state = TIME_OK; | |||
53 | /* clock status bits: */ | 53 | /* clock status bits: */ |
54 | static int time_status = STA_UNSYNC; | 54 | static int time_status = STA_UNSYNC; |
55 | 55 | ||
56 | /* TAI offset (secs): */ | ||
57 | static long time_tai; | ||
58 | |||
59 | /* time adjustment (nsecs): */ | 56 | /* time adjustment (nsecs): */ |
60 | static s64 time_offset; | 57 | static s64 time_offset; |
61 | 58 | ||
@@ -415,7 +412,6 @@ int second_overflow(unsigned long secs) | |||
415 | else if (secs % 86400 == 0) { | 412 | else if (secs % 86400 == 0) { |
416 | leap = -1; | 413 | leap = -1; |
417 | time_state = TIME_OOP; | 414 | time_state = TIME_OOP; |
418 | time_tai++; | ||
419 | printk(KERN_NOTICE | 415 | printk(KERN_NOTICE |
420 | "Clock: inserting leap second 23:59:60 UTC\n"); | 416 | "Clock: inserting leap second 23:59:60 UTC\n"); |
421 | } | 417 | } |
@@ -425,7 +421,6 @@ int second_overflow(unsigned long secs) | |||
425 | time_state = TIME_OK; | 421 | time_state = TIME_OK; |
426 | else if ((secs + 1) % 86400 == 0) { | 422 | else if ((secs + 1) % 86400 == 0) { |
427 | leap = 1; | 423 | leap = 1; |
428 | time_tai--; | ||
429 | time_state = TIME_WAIT; | 424 | time_state = TIME_WAIT; |
430 | printk(KERN_NOTICE | 425 | printk(KERN_NOTICE |
431 | "Clock: deleting leap second 23:59:59 UTC\n"); | 426 | "Clock: deleting leap second 23:59:59 UTC\n"); |
@@ -579,7 +574,9 @@ static inline void process_adj_status(struct timex *txc, struct timespec *ts) | |||
579 | * Called with ntp_lock held, so we can access and modify | 574 | * Called with ntp_lock held, so we can access and modify |
580 | * all the global NTP state: | 575 | * all the global NTP state: |
581 | */ | 576 | */ |
582 | static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts) | 577 | static inline void process_adjtimex_modes(struct timex *txc, |
578 | struct timespec *ts, | ||
579 | s32 *time_tai) | ||
583 | { | 580 | { |
584 | if (txc->modes & ADJ_STATUS) | 581 | if (txc->modes & ADJ_STATUS) |
585 | process_adj_status(txc, ts); | 582 | process_adj_status(txc, ts); |
@@ -613,7 +610,7 @@ static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts | |||
613 | } | 610 | } |
614 | 611 | ||
615 | if (txc->modes & ADJ_TAI && txc->constant > 0) | 612 | if (txc->modes & ADJ_TAI && txc->constant > 0) |
616 | time_tai = txc->constant; | 613 | *time_tai = txc->constant; |
617 | 614 | ||
618 | if (txc->modes & ADJ_OFFSET) | 615 | if (txc->modes & ADJ_OFFSET) |
619 | ntp_update_offset(txc->offset); | 616 | ntp_update_offset(txc->offset); |
@@ -632,6 +629,7 @@ static inline void process_adjtimex_modes(struct timex *txc, struct timespec *ts | |||
632 | int do_adjtimex(struct timex *txc) | 629 | int do_adjtimex(struct timex *txc) |
633 | { | 630 | { |
634 | struct timespec ts; | 631 | struct timespec ts; |
632 | u32 time_tai, orig_tai; | ||
635 | int result; | 633 | int result; |
636 | 634 | ||
637 | /* Validate the data before disabling interrupts */ | 635 | /* Validate the data before disabling interrupts */ |
@@ -671,6 +669,7 @@ int do_adjtimex(struct timex *txc) | |||
671 | } | 669 | } |
672 | 670 | ||
673 | getnstimeofday(&ts); | 671 | getnstimeofday(&ts); |
672 | orig_tai = time_tai = timekeeping_get_tai_offset(); | ||
674 | 673 | ||
675 | raw_spin_lock_irq(&ntp_lock); | 674 | raw_spin_lock_irq(&ntp_lock); |
676 | 675 | ||
@@ -687,7 +686,7 @@ int do_adjtimex(struct timex *txc) | |||
687 | 686 | ||
688 | /* If there are input parameters, then process them: */ | 687 | /* If there are input parameters, then process them: */ |
689 | if (txc->modes) | 688 | if (txc->modes) |
690 | process_adjtimex_modes(txc, &ts); | 689 | process_adjtimex_modes(txc, &ts, &time_tai); |
691 | 690 | ||
692 | txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, | 691 | txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, |
693 | NTP_SCALE_SHIFT); | 692 | NTP_SCALE_SHIFT); |
@@ -716,6 +715,9 @@ int do_adjtimex(struct timex *txc) | |||
716 | 715 | ||
717 | raw_spin_unlock_irq(&ntp_lock); | 716 | raw_spin_unlock_irq(&ntp_lock); |
718 | 717 | ||
718 | if (time_tai != orig_tai) | ||
719 | timekeeping_set_tai_offset(time_tai); | ||
720 | |||
719 | txc->time.tv_sec = ts.tv_sec; | 721 | txc->time.tv_sec = ts.tv_sec; |
720 | txc->time.tv_usec = ts.tv_nsec; | 722 | txc->time.tv_usec = ts.tv_nsec; |
721 | if (!(time_status & STA_NANO)) | 723 | if (!(time_status & STA_NANO)) |