summaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-07-16 21:04:22 +0000
committerJohn Stultz <john.stultz@linaro.org>2014-07-23 10:18:01 -0700
commit9a6b51976ea3a326b6de534beec3fd87275f4ef6 (patch)
tree4f9eed2b231c527dab091620da6354fff97eae28 /kernel/time
parent48064f5f67d58f95094305ac575d5372b58e265f (diff)
downloadlinux-9a6b51976ea3a326b6de534beec3fd87275f4ef6.tar.bz2
timekeeping: Provide ktime_mono_to_any()
ktime based conversion function to map a monotonic time stamp to a different CLOCK. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timekeeping.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index e99350319eec..032e77a54a79 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -451,6 +451,26 @@ ktime_t ktime_get_with_offset(enum tk_offsets offs)
EXPORT_SYMBOL_GPL(ktime_get_with_offset);
/**
+ * ktime_mono_to_any() - convert mononotic time to any other time
+ * @tmono: time to convert.
+ * @offs: which offset to use
+ */
+ktime_t ktime_mono_to_any(ktime_t tmono, enum tk_offsets offs)
+{
+ ktime_t *offset = offsets[offs];
+ unsigned long seq;
+ ktime_t tconv;
+
+ do {
+ seq = read_seqcount_begin(&tk_core.seq);
+ tconv = ktime_add(tmono, *offset);
+ } while (read_seqcount_retry(&tk_core.seq, seq));
+
+ return tconv;
+}
+EXPORT_SYMBOL_GPL(ktime_mono_to_any);
+
+/**
* ktime_get_ts64 - get the monotonic clock in timespec64 format
* @ts: pointer to timespec variable
*