Commit bd416103 authored by Bryan O'Donoghue's avatar Bryan O'Donoghue Committed by Greg Kroah-Hartman

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: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 67d1eece
...@@ -283,6 +283,15 @@ static struct attribute *loopback_attrs[] = { ...@@ -283,6 +283,15 @@ static struct attribute *loopback_attrs[] = {
}; };
ATTRIBUTE_GROUPS(loopback); 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) static u64 gb_loopback_calc_latency(struct timeval *ts, struct timeval *te)
{ {
u64 t1, t2; u64 t1, t2;
...@@ -532,9 +541,7 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb) ...@@ -532,9 +541,7 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb)
u64 tmp; u64 tmp;
/* Express latency in terms of microseconds */ /* Express latency in terms of microseconds */
tmp = gb->elapsed_nsecs; lat = gb_loopback_nsec_to_usec_latency(gb->elapsed_nsecs);
do_div(tmp, NSEC_PER_USEC);
lat = tmp;
/* Log latency statistic */ /* Log latency statistic */
gb_loopback_update_stats(&gb_dev.latency, lat); gb_loopback_update_stats(&gb_dev.latency, lat);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment