Message ID | 1419594103-10928-5-git-send-email-mpa@pengutronix.de (mailing list archive) |
---|---|
State | Rejected, archived |
Headers |
Return-Path: <mpa@pengutronix.de> Received-SPF: None (no SPF record) identity=mailfrom; client-ip=92.198.50.35; helo=metis.ext.pengutronix.de; envelope-from=mpa@pengutronix.de; receiver=b.a.t.m.a.n@lists.open-mesh.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by open-mesh.org (Postfix) with ESMTPS id 71C02600401 for <b.a.t.m.a.n@lists.open-mesh.org>; Fri, 26 Dec 2014 12:44:58 +0100 (CET) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from <mpa@pengutronix.de>) id 1Y4TKA-0001i1-9u; Fri, 26 Dec 2014 12:44:54 +0100 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from <mpa@pengutronix.de>) id 1Y4TK8-000626-TV; Fri, 26 Dec 2014 12:44:52 +0100 From: Markus Pargmann <mpa@pengutronix.de> To: Marek Lindner <mareklindner@neomailbox.ch>, Simon Wunderlich <sw@simonwunderlich.de>, Antonio Quartulli <antonio@meshcoding.com> Date: Fri, 26 Dec 2014 12:41:21 +0100 Message-Id: <1419594103-10928-5-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1419594103-10928-1-git-send-email-mpa@pengutronix.de> References: <1419594103-10928-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: b.a.t.m.a.n@lists.open-mesh.org Cc: b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann <sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH v2 04/26] batman-adv: iv_ogm, divide and round for ring buffer avg X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n@lists.open-mesh.org> List-Id: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n.lists.open-mesh.org> List-Unsubscribe: <https://lists.open-mesh.org/mm/options/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=unsubscribe> List-Archive: <http://lists.open-mesh.org/pipermail/b.a.t.m.a.n/> List-Post: <mailto:b.a.t.m.a.n@lists.open-mesh.org> List-Help: <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=help> List-Subscribe: <https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=subscribe> X-List-Received-Date: Fri, 26 Dec 2014 11:44:58 -0000 |
Commit Message
Markus Pargmann
Dec. 26, 2014, 11:41 a.m. UTC
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(-)
Comments
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
On Sunday 11 January 2015 20:32:49 Marek Lindner wrote: > 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 ? It was introduced in 2.6.29 in v2.6.28-6240-g9fe0608. So you would only need compat code in marek/compat_old_kernel Kind regards, Sven
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> (sorry for the duplicate, sent the reply for the first patch version, so I'm replying another time on v2 ...) Why do we need to have more precise rounding here? In doubt, we should rather always round down to avoid any spurious routing loops - the loop free property depends on monotonicity after all, and therefore its better to always round down. I'm not convinced that this change is safe in that regard, if you think it is please explain further. > --- > 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); > } > > /**
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); } /**