mac80211: reduce calculation costs of EWMA
[cascardo/linux.git] / net / mac80211 / rc80211_minstrel.h
index 0083036..9c85a61 100644 (file)
 static inline int
 minstrel_ewma(int old, int new, int weight)
 {
-       return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV;
+       int diff, incr;
+
+       diff = new - old;
+       incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
+
+       return old + incr;
 }
 
 struct minstrel_rate_stats {