greybus: loopback: Fix averaging
authorAlexandre Bailon <abailon@baylibre.com>
Thu, 25 Feb 2016 17:19:16 +0000 (18:19 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 26 Feb 2016 01:05:31 +0000 (17:05 -0800)
commitfb37f137b78f186275b15e8ce1e5a26b51a6e6ad
tree11812af9c747f7eed2c013ed6825a4b5802132db
parentab81bb9c68d9fb899b79fa622fedf294e66fa53d
greybus: loopback: Fix averaging

Currently, we are adding 0.5 to the average to round the average.
But we are using the remainder to calculate the decimal, so we do not
need to round the average.
In addition, use a u64 type for the remainder to avoid overflow
that might happen when stats->sum value is too big,
usually for requests per seconds and the throughput.

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