ath9k: fix TSF offset precision issue
authorFelix Fietkau <nbd@openwrt.org>
Thu, 19 Dec 2013 17:01:50 +0000 (18:01 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 19 Dec 2013 19:41:56 +0000 (14:41 -0500)
Dividing the beacon interval by ATH_BCBUF (8) truncates the result for
the default beacon interval of 100.
Fix the calculation by moving the division after conversion from TU to
microseconds.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/beacon.c

index accfb3b60daa0c0da839928c9ae1e6f551905111..112aff720e1377791ab939616b6c0b2ed9598e3e 100644 (file)
@@ -279,13 +279,14 @@ static void ath9k_set_tsfadjust(struct ath_softc *sc, struct ieee80211_vif *vif)
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        struct ath_beacon_config *cur_conf = &sc->cur_beacon_conf;
        struct ath_vif *avp = (void *)vif->drv_priv;
-       u64 tsfadjust;
+       u32 tsfadjust;
 
        if (avp->av_bslot == 0)
                return;
 
-       tsfadjust = cur_conf->beacon_interval * avp->av_bslot / ATH_BCBUF;
-       avp->tsf_adjust = cpu_to_le64(TU_TO_USEC(tsfadjust));
+       tsfadjust = cur_conf->beacon_interval * avp->av_bslot;
+       tsfadjust = TU_TO_USEC(tsfadjust) / ATH_BCBUF;
+       avp->tsf_adjust = cpu_to_le64(tsfadjust);
 
        ath_dbg(common, CONFIG, "tsfadjust is: %llu for bslot: %d\n",
                (unsigned long long)tsfadjust, avp->av_bslot);