[CCID3]: Inline for moving average

The moving average computation occurs so frequently in the CCID 3 code that
it merits an inline function  of its own. This is uses a suggestion by
Arnaldo as per http://www.mail-archive.com/dccp@vger.kernel.org/msg01662.html

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Gerrit Renker
2007-11-20 18:09:59 -02:00
committed by David S. Miller
parent a5358fdc9c
commit c3ada46a00
2 changed files with 14 additions and 20 deletions

View File

@ -37,6 +37,15 @@ static inline u32 scaled_div32(u64 a, u32 b)
return result;
}
/**
* tfrc_ewma - Exponentially weighted moving average
* @weight: Weight to be used as damping factor, in units of 1/10
*/
static inline u32 tfrc_ewma(const u32 avg, const u32 newval, const u8 weight)
{
return avg ? (weight * avg + (10 - weight) * newval) / 10 : newval;
}
extern u32 tfrc_calc_x(u16 s, u32 R, u32 p);
extern u32 tfrc_calc_x_reverse_lookup(u32 fvalue);