From 7c985351d40475ab752b230d5761e646973cb59b Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Mon, 17 Aug 2015 00:55:06 +0100 Subject: [PATCH] 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 4879edda982a..39375f1e0d8e 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -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) -- 2.20.1