greybus: loopback: round closest the sixth decimal
authorAlexandre Bailon <abailon@baylibre.com>
Tue, 8 Mar 2016 15:37:37 +0000 (16:37 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 10 Mar 2016 06:31:32 +0000 (22:31 -0800)
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>
drivers/staging/greybus/loopback.c

index 75bff56..9f1cd9d 100644 (file)
@@ -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);                                             \