]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
hwclock: fix conversion of HW timestamps
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 4 Aug 2017 13:08:40 +0000 (15:08 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 9 Aug 2017 07:57:14 +0000 (09:57 +0200)
Fix a sign error in conversion of HW time to local time, which caused
the jitter to be amplified instead of reduced. NTP with HW timestamping
should now be more stable and able to ignore occasionally delayed
readings of PHC.

hwclock.c

index b81612778b6105b90ef2eb95b4c27d119323a2ec..84a130df6e9ff85477dfacb0359aca6c924d7dd5 100644 (file)
--- a/hwclock.c
+++ b/hwclock.c
@@ -198,7 +198,7 @@ HCL_CookTime(HCL_Instance clock, struct timespec *raw, struct timespec *cooked,
     return 0;
 
   elapsed = UTI_DiffTimespecsToDouble(raw, &clock->hw_ref);
-  offset = clock->offset + elapsed / clock->frequency;
+  offset = elapsed / clock->frequency - clock->offset;
   UTI_AddDoubleToTimespec(&clock->local_ref, offset, cooked);
 
   /* Fow now, just return the error of the last sample */