From: Alexandre Bailon <abailon@baylibre.com>
Date: Tue, 8 Mar 2016 15:37:37 +0000 (+0100)
Subject: greybus: loopback: round closest the sixth decimal
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=58a527afff2b27bc912dbb7111d3f23d4f28105b;p=linux.git

greybus: loopback: round closest the sixth decimal

The original round was removed becaused it was rounding
the integer whereas we had decimals.
Round the sixth decimal.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
---

diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 75bff56b48c3c..9f1cd9d6cd546 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -162,7 +162,7 @@ static ssize_t name##_avg_show(struct device *dev,		\
 	gb = dev_get_drvdata(dev);			\
 	stats = &gb->name;					\
 	count = stats->count ? stats->count : 1;			\
-	avg = stats->sum;						\
+	avg = stats->sum + count / 2000000; /* round closest */		\
 	rem = do_div(avg, count);					\
 	rem *= 1000000;							\
 	do_div(rem, count);						\