Commit 153b5d054ac2d98ea0d86504884326b6777f683d
Committed by
Linus Torvalds
1 parent
9f14f669d1
ntp: support for TAI
This adds support for setting the TAI value (International Atomic Time). The value is reported back to userspace via timex (as we don't have a ntp_gettime() syscall). Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Cc: john stultz <johnstul@us.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 4 changed files with 15 additions and 3 deletions Side-by-side Diff
include/linux/compat.h
... | ... | @@ -65,10 +65,11 @@ |
65 | 65 | compat_long_t calcnt; |
66 | 66 | compat_long_t errcnt; |
67 | 67 | compat_long_t stbcnt; |
68 | + compat_int_t tai; | |
68 | 69 | |
69 | 70 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; |
70 | 71 | compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; |
71 | - compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32; | |
72 | + compat_int_t :32; compat_int_t :32; compat_int_t :32; | |
72 | 73 | }; |
73 | 74 | |
74 | 75 | #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) |
include/linux/timex.h
... | ... | @@ -121,9 +121,11 @@ |
121 | 121 | long errcnt; /* calibration errors (ro) */ |
122 | 122 | long stbcnt; /* stability limit exceeded (ro) */ |
123 | 123 | |
124 | + int tai; /* TAI offset (ro) */ | |
125 | + | |
124 | 126 | int :32; int :32; int :32; int :32; |
125 | 127 | int :32; int :32; int :32; int :32; |
126 | - int :32; int :32; int :32; int :32; | |
128 | + int :32; int :32; int :32; | |
127 | 129 | }; |
128 | 130 | |
129 | 131 | /* |
... | ... | @@ -135,6 +137,7 @@ |
135 | 137 | #define ADJ_ESTERROR 0x0008 /* estimated time error */ |
136 | 138 | #define ADJ_STATUS 0x0010 /* clock status */ |
137 | 139 | #define ADJ_TIMECONST 0x0020 /* pll time constant */ |
140 | +#define ADJ_TAI 0x0080 /* set TAI offset */ | |
138 | 141 | #define ADJ_MICRO 0x1000 /* select microsecond resolution */ |
139 | 142 | #define ADJ_NANO 0x2000 /* select nanosecond resolution */ |
140 | 143 | #define ADJ_TICK 0x4000 /* tick value */ |
kernel/compat.c
... | ... | @@ -955,7 +955,8 @@ |
955 | 955 | __put_user(txc.jitcnt, &utp->jitcnt) || |
956 | 956 | __put_user(txc.calcnt, &utp->calcnt) || |
957 | 957 | __put_user(txc.errcnt, &utp->errcnt) || |
958 | - __put_user(txc.stbcnt, &utp->stbcnt)) | |
958 | + __put_user(txc.stbcnt, &utp->stbcnt) || | |
959 | + __put_user(txc.tai, &utp->tai)) | |
959 | 960 | ret = -EFAULT; |
960 | 961 | |
961 | 962 | return ret; |
kernel/time/ntp.c
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | /* TIME_ERROR prevents overwriting the CMOS clock */ |
36 | 36 | static int time_state = TIME_OK; /* clock synchronization status */ |
37 | 37 | int time_status = STA_UNSYNC; /* clock status bits */ |
38 | +static long time_tai; /* TAI offset (s) */ | |
38 | 39 | static s64 time_offset; /* time adjustment (ns) */ |
39 | 40 | static long time_constant = 2; /* pll time constant */ |
40 | 41 | long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */ |
... | ... | @@ -162,6 +163,7 @@ |
162 | 163 | case TIME_DEL: |
163 | 164 | if ((xtime.tv_sec + 1) % 86400 == 0) { |
164 | 165 | xtime.tv_sec++; |
166 | + time_tai--; | |
165 | 167 | wall_to_monotonic.tv_sec--; |
166 | 168 | time_state = TIME_WAIT; |
167 | 169 | printk(KERN_NOTICE "Clock: deleting leap second " |
... | ... | @@ -169,6 +171,7 @@ |
169 | 171 | } |
170 | 172 | break; |
171 | 173 | case TIME_OOP: |
174 | + time_tai++; | |
172 | 175 | time_state = TIME_WAIT; |
173 | 176 | break; |
174 | 177 | case TIME_WAIT: |
... | ... | @@ -340,6 +343,9 @@ |
340 | 343 | time_constant = max(time_constant, 0l); |
341 | 344 | } |
342 | 345 | |
346 | + if (txc->modes & ADJ_TAI && txc->constant > 0) | |
347 | + time_tai = txc->constant; | |
348 | + | |
343 | 349 | if (txc->modes & ADJ_OFFSET) { |
344 | 350 | if (txc->modes == ADJ_OFFSET_SINGLESHOT) |
345 | 351 | /* adjtime() is independent from ntp_adjtime() */ |
... | ... | @@ -377,6 +383,7 @@ |
377 | 383 | txc->precision = 1; |
378 | 384 | txc->tolerance = MAXFREQ_SCALED / PPM_SCALE; |
379 | 385 | txc->tick = tick_usec; |
386 | + txc->tai = time_tai; | |
380 | 387 | |
381 | 388 | /* PPS is not implemented, so these are zero */ |
382 | 389 | txc->ppsfreq = 0; |