]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Fix frequency accumulation
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 21 Apr 2010 08:29:04 +0000 (10:29 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 21 Apr 2010 11:59:37 +0000 (13:59 +0200)
local.c
rtc_linux.c

diff --git a/local.c b/local.c
index 1be61174cceb5a77712519e3689d70ab24ecab1f..3c5efb35523b2e8c4d38488e0c0c0f85e51e85c3 100644 (file)
--- a/local.c
+++ b/local.c
@@ -378,7 +378,7 @@ LCL_SetAbsoluteFrequency(double afreq_ppm)
   
   (*drv_set_freq)(afreq_ppm);
 
-  dfreq = 1.0e-6 * (afreq_ppm - current_freq_ppm) / (1.0 - 1.0e-6 * current_freq_ppm);
+  dfreq = (afreq_ppm - current_freq_ppm) / (1.0e6 + current_freq_ppm);
 
   LCL_ReadRawTime(&raw);
   LCL_CookTime(&raw, &cooked, NULL);
@@ -404,8 +404,7 @@ LCL_AccumulateDeltaFrequency(double dfreq)
    are handled in units of ppm, whereas the 'dfreq' argument is in
    terms of the gradient of the (offset) v (local time) function. */
 
-  current_freq_ppm = (1.0 - dfreq) * current_freq_ppm +
-    (1.0e6 * dfreq);
+  current_freq_ppm = (1.0 + dfreq) * current_freq_ppm + 1.0e6 * dfreq;
 
   /* Call the system-specific driver for setting the frequency */
   (*drv_set_freq)(current_freq_ppm);
@@ -485,8 +484,7 @@ LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset)
   /* Work out new absolute frequency.  Note that absolute frequencies
    are handled in units of ppm, whereas the 'dfreq' argument is in
    terms of the gradient of the (offset) v (local time) function. */
-  current_freq_ppm = (1.0 - dfreq) * old_freq_ppm +
-    (1.0e6 * dfreq);
+  current_freq_ppm = (1.0 + dfreq) * old_freq_ppm + 1.0e6 * dfreq;
 
 #ifdef TRACEON
   LOG(LOGS_INFO, LOGF_Local, "old_freq=%.3fppm new_freq=%.3fppm offset=%.6fsec",
index 3a7cd1ba662fb8c33584d87cd2016e0bc7447e4e..581411186132bd401fb8d6b0db6b40961bc687e9 100644 (file)
@@ -314,7 +314,7 @@ slew_samples
   double old_seconds_fast, old_gain_rate;
 
   new_freq = 1.0e-6 * afreq_ppm;
-  old_freq = (new_freq - dfreq) / (1.0 - dfreq);
+  old_freq = (new_freq - dfreq) / (1.0 + dfreq);
 
   for (i=0; i<n_samples; i++) {
     UTI_DiffTimevalsToDouble(&elapsed, cooked, system_times + i);