aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/ntp.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time/ntp.c')
-rw-r--r--kernel/time/ntp.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 1ab5e9d7fa50..47195fa0ec4f 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -30,17 +30,31 @@ static u64 tick_length, tick_length_base;
30 * phase-lock loop variables 30 * phase-lock loop variables
31 */ 31 */
32/* TIME_ERROR prevents overwriting the CMOS clock */ 32/* TIME_ERROR prevents overwriting the CMOS clock */
33int time_state = TIME_OK; /* clock synchronization status */ 33static int time_state = TIME_OK; /* clock synchronization status */
34int time_status = STA_UNSYNC; /* clock status bits */ 34int time_status = STA_UNSYNC; /* clock status bits */
35long time_offset; /* time adjustment (ns) */ 35static long time_offset; /* time adjustment (ns) */
36long time_constant = 2; /* pll time constant */ 36static long time_constant = 2; /* pll time constant */
37long time_precision = 1; /* clock precision (us) */
38long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */ 37long time_maxerror = NTP_PHASE_LIMIT; /* maximum error (us) */
39long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */ 38long time_esterror = NTP_PHASE_LIMIT; /* estimated error (us) */
40long time_freq; /* frequency offset (scaled ppm)*/ 39long time_freq; /* frequency offset (scaled ppm)*/
41long time_reftime; /* time at last adjustment (s) */ 40static long time_reftime; /* time at last adjustment (s) */
42long time_adjust; 41long time_adjust;
43 42
43#define CLOCK_TICK_OVERFLOW (LATCH * HZ - CLOCK_TICK_RATE)
44#define CLOCK_TICK_ADJUST (((s64)CLOCK_TICK_OVERFLOW * NSEC_PER_SEC) / \
45 (s64)CLOCK_TICK_RATE)
46
47static void ntp_update_frequency(void)
48{
49 tick_length_base = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) << TICK_LENGTH_SHIFT;
50 tick_length_base += (s64)CLOCK_TICK_ADJUST << TICK_LENGTH_SHIFT;
51 tick_length_base += (s64)time_freq << (TICK_LENGTH_SHIFT - SHIFT_NSEC);
52
53 do_div(tick_length_base, HZ);
54
55 tick_nsec = tick_length_base >> TICK_LENGTH_SHIFT;
56}
57
44/** 58/**
45 * ntp_clear - Clears the NTP state variables 59 * ntp_clear - Clears the NTP state variables
46 * 60 *
@@ -59,20 +73,6 @@ void ntp_clear(void)
59 time_offset = 0; 73 time_offset = 0;
60} 74}
61 75
62#define CLOCK_TICK_OVERFLOW (LATCH * HZ - CLOCK_TICK_RATE)
63#define CLOCK_TICK_ADJUST (((s64)CLOCK_TICK_OVERFLOW * NSEC_PER_SEC) / (s64)CLOCK_TICK_RATE)
64
65void ntp_update_frequency(void)
66{
67 tick_length_base = (u64)(tick_usec * NSEC_PER_USEC * USER_HZ) << TICK_LENGTH_SHIFT;
68 tick_length_base += (s64)CLOCK_TICK_ADJUST << TICK_LENGTH_SHIFT;
69 tick_length_base += (s64)time_freq << (TICK_LENGTH_SHIFT - SHIFT_NSEC);
70
71 do_div(tick_length_base, HZ);
72
73 tick_nsec = tick_length_base >> TICK_LENGTH_SHIFT;
74}
75
76/* 76/*
77 * this routine handles the overflow of the microsecond field 77 * this routine handles the overflow of the microsecond field
78 * 78 *
@@ -330,7 +330,7 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0)
330 txc->esterror = time_esterror; 330 txc->esterror = time_esterror;
331 txc->status = time_status; 331 txc->status = time_status;
332 txc->constant = time_constant; 332 txc->constant = time_constant;
333 txc->precision = time_precision; 333 txc->precision = 1;
334 txc->tolerance = MAXFREQ; 334 txc->tolerance = MAXFREQ;
335 txc->tick = tick_usec; 335 txc->tick = tick_usec;
336 336