From db93180ce14a55abdc3c820129b0199142a1a050 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 15 Jun 2017 11:16:57 +0200 Subject: [PATCH] ntp: apply HW TX/RX compensation to system time Apply the compensation to the cooked local time instead of HW time. This might make a difference when the HW clock has a large frequency error. --- ntp_io_linux.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ntp_io_linux.c b/ntp_io_linux.c index 5a50677..736aea5 100644 --- a/ntp_io_linux.c +++ b/ntp_io_linux.c @@ -451,14 +451,14 @@ process_hw_timestamp(struct Interface *iface, struct timespec *hw_ts, UTI_AddDoubleToTimespec(hw_ts, rx_correction, hw_ts); } - if (!rx_ntp_length && iface->tx_comp) - UTI_AddDoubleToTimespec(hw_ts, iface->tx_comp, hw_ts); - else if (rx_ntp_length && iface->rx_comp) - UTI_AddDoubleToTimespec(hw_ts, -iface->rx_comp, hw_ts); - if (!HCL_CookTime(iface->clock, hw_ts, &ts, &local_err)) return; + if (!rx_ntp_length && iface->tx_comp) + UTI_AddDoubleToTimespec(&ts, iface->tx_comp, &ts); + else if (rx_ntp_length && iface->rx_comp) + UTI_AddDoubleToTimespec(&ts, -iface->rx_comp, &ts); + ts_delay = UTI_DiffTimespecsToDouble(&local_ts->ts, &ts); if (fabs(ts_delay) > MAX_TS_DELAY) {