]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/hrtimer.c
[IPG]: add IP1000A driver to kernel tree
[linux-2.6-omap-h63xx.git] / kernel / hrtimer.c
index c21ca6bfaa6600dd864ef1b32798dc1a4ae8c081..dc8a4451d79b15d64a37caf55c9dc4595c6ec5d2 100644 (file)
@@ -277,6 +277,30 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec)
 }
 
 EXPORT_SYMBOL_GPL(ktime_add_ns);
+
+/**
+ * ktime_sub_ns - Subtract a scalar nanoseconds value from a ktime_t variable
+ * @kt:                minuend
+ * @nsec:      the scalar nsec value to subtract
+ *
+ * Returns the subtraction of @nsec from @kt in ktime_t format
+ */
+ktime_t ktime_sub_ns(const ktime_t kt, u64 nsec)
+{
+       ktime_t tmp;
+
+       if (likely(nsec < NSEC_PER_SEC)) {
+               tmp.tv64 = nsec;
+       } else {
+               unsigned long rem = do_div(nsec, NSEC_PER_SEC);
+
+               tmp = ktime_set((long)nsec, rem);
+       }
+
+       return ktime_sub(kt, tmp);
+}
+
+EXPORT_SYMBOL_GPL(ktime_sub_ns);
 # endif /* !CONFIG_KTIME_SCALAR */
 
 /*