Firmware sometimes returns erroneous timestamps(2)
authorIanR778 <ianr778@zippymail.info>
Wed, 8 Oct 2014 00:14:01 +0000 (01:14 +0100)
committerIanR778 <ianr778@zippymail.info>
Wed, 8 Oct 2014 00:14:01 +0000 (01:14 +0100)
Fixed incorrect wrapping handling in ath_extend_tsf().

target_firmware/wlan/if_ath.c

index 864f48f8229f47f919d96aea4aa3dea33b2c30af..206b5c0e2c674d0a417f7db530791b130b19b2bb 100755 (executable)
@@ -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)