greybus: loopback: functionally decompose gb_loopback_calc_latency

The __gb_loopback_calc_latency will be useful in later patches. Provide it
here and use as intended. Later on we just want to use the timestamp
rollover detection, so split it out now.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Bryan O'Donoghue 2015-08-17 00:55:06 +01:00 committed by Greg Kroah-Hartman
parent bd416103b2
commit 7c985351d4

View File

@ -292,16 +292,22 @@ static u32 gb_loopback_nsec_to_usec_latency(u64 elapsed_nsecs)
return lat;
}
static u64 __gb_loopback_calc_latency(u64 t1, u64 t2)
{
if (t2 > t1)
return t2 - t1;
else
return NSEC_PER_DAY - t2 + t1;
}
static u64 gb_loopback_calc_latency(struct timeval *ts, struct timeval *te)
{
u64 t1, t2;
t1 = timeval_to_ns(ts);
t2 = timeval_to_ns(te);
if (t2 > t1)
return t2 - t1;
else
return NSEC_PER_DAY - t2 + t1;
return __gb_loopback_calc_latency(t1, t2);
}
static int gb_loopback_sink(struct gb_loopback *gb, u32 len)