From: Bryan O'Donoghue Date: Sun, 16 Aug 2015 23:55:05 +0000 (+0100) Subject: greybus: loopback: add gb_loopback_nsec_to_usec_latency X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bd416103b204494e29b095e28c5a7b6a77e8f2b9;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git greybus: loopback: add gb_loopback_nsec_to_usec_latency A helper function to convert from a nanosecond value to a latency value expressed in mircoseconds. This will be used again in subsequent patches. Signed-off-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index b46ded22b533..4879edda982a 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -283,6 +283,15 @@ static struct attribute *loopback_attrs[] = { }; ATTRIBUTE_GROUPS(loopback); +static u32 gb_loopback_nsec_to_usec_latency(u64 elapsed_nsecs) +{ + u32 lat; + + do_div(elapsed_nsecs, NSEC_PER_USEC); + lat = elapsed_nsecs; + return lat; +} + static u64 gb_loopback_calc_latency(struct timeval *ts, struct timeval *te) { u64 t1, t2; @@ -532,9 +541,7 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb) u64 tmp; /* Express latency in terms of microseconds */ - tmp = gb->elapsed_nsecs; - do_div(tmp, NSEC_PER_USEC); - lat = tmp; + lat = gb_loopback_nsec_to_usec_latency(gb->elapsed_nsecs); /* Log latency statistic */ gb_loopback_update_stats(&gb_dev.latency, lat);