]> Pileus Git - ~andy/linux/commitdiff
ktime: add ms_to_ktime() and ktime_add_ms() helpers
authorDaniel Borkmann <dborkman@redhat.com>
Tue, 25 Jun 2013 16:17:26 +0000 (18:17 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Jun 2013 23:33:04 +0000 (16:33 -0700)
Add two ktime helper functions that i) convert a given msec value to
a ktime structure and ii) that adds a msec value to a ktime structure.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/ktime.h

index bbca12804d12434ebfb100487c460c2ed21f99ed..b4fa5e4cd158dfa5e8bdda0c9e14df77818abe65 100644 (file)
@@ -323,6 +323,11 @@ static inline ktime_t ktime_add_us(const ktime_t kt, const u64 usec)
        return ktime_add_ns(kt, usec * 1000);
 }
 
+static inline ktime_t ktime_add_ms(const ktime_t kt, const u64 msec)
+{
+       return ktime_add_ns(kt, msec * NSEC_PER_MSEC);
+}
+
 static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec)
 {
        return ktime_sub_ns(kt, usec * 1000);
@@ -366,7 +371,15 @@ extern void ktime_get_ts(struct timespec *ts);
 static inline ktime_t ns_to_ktime(u64 ns)
 {
        static const ktime_t ktime_zero = { .tv64 = 0 };
+
        return ktime_add_ns(ktime_zero, ns);
 }
 
+static inline ktime_t ms_to_ktime(u64 ms)
+{
+       static const ktime_t ktime_zero = { .tv64 = 0 };
+
+       return ktime_add_ms(ktime_zero, ms);
+}
+
 #endif