Re: [B.A.T.M.A.N.] [PATCH v2 04/26] batman-adv: iv_ogm, divide and round for ring buffer avg

Marek Lindner
2015-01-11T12:32:49Z

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

On Friday 26 December 2014 12:41:21 Markus Pargmann wrote:
> Instead of the normal division which looses precision, use a division
> with rounding.
>
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
> bat_iv_ogm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
> index 1458ecfa66b8..10eada270015 100644
> --- a/bat_iv_ogm.c
> +++ b/bat_iv_ogm.c
> @@ -82,7 +82,7 @@ static uint8_t batadv_ring_buffer_avg(const uint8_t
> lq_recv[]) if (count == 0)
> return 0;
>
> - return (uint8_t)(sum / count);
> + return (uint8_t)DIV_ROUND_CLOSEST(sum, count);
> }

Is DIV_ROUND_CLOSEST available in 2.6.29 ? I could not find a conclusive hint
whether or not we need compat code for the out-of-tree module ?

Cheers,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]