timekeeping: Provide ktime_get[*]_ns() helpers
authorThomas Gleixner <tglx@linutronix.de>
Wed, 16 Jul 2014 21:04:29 +0000 (21:04 +0000)
committerJohn Stultz <john.stultz@linaro.org>
Wed, 23 Jul 2014 17:18:04 +0000 (10:18 -0700)
A lot of code converts either timespecs or ktime_t to
nanoseconds. Provide helper functions.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
include/linux/timekeeping.h

index 64c81f367866d8d61b049e6bdc146bb4c3fecf02..903ecc10fcff77efd0c19656031fd8825f7d9228 100644 (file)
@@ -145,6 +145,21 @@ static inline ktime_t ktime_mono_to_real(ktime_t mono)
        return ktime_mono_to_any(mono, TK_OFFS_REAL);
 }
 
+static inline u64 ktime_get_ns(void)
+{
+       return ktime_to_ns(ktime_get());
+}
+
+static inline u64 ktime_get_real_ns(void)
+{
+       return ktime_to_ns(ktime_get_real());
+}
+
+static inline u64 ktime_get_boot_ns(void)
+{
+       return ktime_to_ns(ktime_get_boottime());
+}
+
 /*
  * RTC specific
  */