From: IanR778 Date: Wed, 8 Oct 2014 00:14:01 +0000 (+0100) Subject: Firmware sometimes returns erroneous timestamps(2) X-Git-Tag: 1.4.0~1^2~2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=583a029b620214fce590e7fbb960dbba290afe23;p=librecmc%2Fopen-ath9k-htc-firmware.git Firmware sometimes returns erroneous timestamps(2) Fixed incorrect wrapping handling in ath_extend_tsf(). --- diff --git a/target_firmware/wlan/if_ath.c b/target_firmware/wlan/if_ath.c index 864f48f..206b5c0 100755 --- a/target_firmware/wlan/if_ath.c +++ b/target_firmware/wlan/if_ath.c @@ -88,20 +88,13 @@ static u_int64_t ath_extend_tsf(struct ath_softc_tgt *sc, u_int32_t rstamp) { struct ath_hal *ah = sc->sc_ah; u_int64_t tsf; - u_int32_t tsf_low; - u_int64_t tsf64; tsf = ah->ah_getTsf64(ah); - tsf_low = tsf & 0xffffffff; - tsf64 = (tsf & ~0xffffffffULL) | rstamp; - if (rstamp > tsf_low && (rstamp - tsf_low > 0x10000000)) - tsf64 -= 0x100000000ULL; + if (rstamp > (tsf & 0xffffffffULL)) + tsf -= 0x100000000ULL; - if (rstamp < tsf_low && (tsf_low - rstamp > 0x10000000)) - tsf64 += 0x100000000ULL; - - return tsf64; + return ((tsf & ~0xffffffffULL) | rstamp); } static a_int32_t ath_rate_setup(struct ath_softc_tgt *sc, a_uint32_t mode)