diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-25 12:17:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-25 19:33:04 -0400 |
commit | d36f82b2435690d8742235d7bdc5bb5e878077e3 (patch) | |
tree | 3c7be59f00d0a8b3692a9d7d8b194bf02785886c /include/linux/ktime.h | |
parent | f072d7aba79c73c3bb4ff1a9b58be5525d755d27 (diff) |
ktime: add ms_to_ktime() and ktime_add_ms() helpers
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>
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r-- | include/linux/ktime.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index bbca12804d12..b4fa5e4cd158 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
@@ -323,6 +323,11 @@ static inline ktime_t ktime_add_us(const ktime_t kt, const u64 usec) | |||
323 | return ktime_add_ns(kt, usec * 1000); | 323 | return ktime_add_ns(kt, usec * 1000); |
324 | } | 324 | } |
325 | 325 | ||
326 | static inline ktime_t ktime_add_ms(const ktime_t kt, const u64 msec) | ||
327 | { | ||
328 | return ktime_add_ns(kt, msec * NSEC_PER_MSEC); | ||
329 | } | ||
330 | |||
326 | static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec) | 331 | static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec) |
327 | { | 332 | { |
328 | return ktime_sub_ns(kt, usec * 1000); | 333 | return ktime_sub_ns(kt, usec * 1000); |
@@ -366,7 +371,15 @@ extern void ktime_get_ts(struct timespec *ts); | |||
366 | static inline ktime_t ns_to_ktime(u64 ns) | 371 | static inline ktime_t ns_to_ktime(u64 ns) |
367 | { | 372 | { |
368 | static const ktime_t ktime_zero = { .tv64 = 0 }; | 373 | static const ktime_t ktime_zero = { .tv64 = 0 }; |
374 | |||
369 | return ktime_add_ns(ktime_zero, ns); | 375 | return ktime_add_ns(ktime_zero, ns); |
370 | } | 376 | } |
371 | 377 | ||
378 | static inline ktime_t ms_to_ktime(u64 ms) | ||
379 | { | ||
380 | static const ktime_t ktime_zero = { .tv64 = 0 }; | ||
381 | |||
382 | return ktime_add_ms(ktime_zero, ms); | ||
383 | } | ||
384 | |||
372 | #endif | 385 | #endif |