]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
greybus: loopback: functionally decompose gb_loopback_calc_latency
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Sun, 16 Aug 2015 23:55:06 +0000 (00:55 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 18 Aug 2015 16:45:23 +0000 (09:45 -0700)
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>
drivers/staging/greybus/loopback.c

index 4879edda982a328f445cce390e9dd81fe08ebb27..39375f1e0d8ef888cae275456340b1c00f43860c 100644 (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)