backports: add ktime_get_raw()
authorHauke Mehrtens <hauke@hauke-m.de>
Sat, 9 Aug 2014 11:42:40 +0000 (13:42 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 9 Aug 2014 14:40:30 +0000 (16:40 +0200)
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
backport/backport-include/linux/ktime.h [new file with mode: 0644]
backport/compat/backport-3.17.c

diff --git a/backport/backport-include/linux/ktime.h b/backport/backport-include/linux/ktime.h
new file mode 100644 (file)
index 0000000..adefc27
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef __BACKPORT_LINUX_KTIME_H
+#define __BACKPORT_LINUX_KTIME_H
+#include_next <linux/ktime.h>
+#include <linux/version.h>
+
+#if  LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#define ktime_get_raw LINUX_BACKPORT(ktime_get_raw)
+extern ktime_t ktime_get_raw(void);
+
+#endif /* < 3.17 */
+
+#endif /* __BACKPORT_LINUX_KTIME_H */
index 9cc0a82fe6e0b769cbbcd07c5347ec5d79cd06a2..567f0c3bd67491fb418adc0c8e7985fb729284b9 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/wait.h>
 #include <linux/sched.h>
 #include <linux/export.h>
+#include <linux/ktime.h>
 
 int bit_wait(void *word)
 {
@@ -25,3 +26,14 @@ int bit_wait_io(void *word)
 }
 EXPORT_SYMBOL_GPL(bit_wait_io);
 
+/**
+ * ktime_get_raw - Returns the raw monotonic time in ktime_t format
+ */
+ktime_t ktime_get_raw(void)
+{
+       struct timespec ts;
+
+       getrawmonotonic(&ts);
+       return timespec_to_ktime(ts);
+}
+EXPORT_SYMBOL_GPL(ktime_get_raw);