diff options
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r-- | include/linux/ktime.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index ce5983225be4..e1ceaa9b36bb 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
@@ -130,7 +130,7 @@ static inline ktime_t timeval_to_ktime(struct timeval tv) | |||
130 | /* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */ | 130 | /* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */ |
131 | #define ktime_to_ns(kt) ((kt).tv64) | 131 | #define ktime_to_ns(kt) ((kt).tv64) |
132 | 132 | ||
133 | #else | 133 | #else /* !((BITS_PER_LONG == 64) || defined(CONFIG_KTIME_SCALAR)) */ |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * Helper macros/inlines to get the ktime_t math right in the timespec | 136 | * Helper macros/inlines to get the ktime_t math right in the timespec |
@@ -275,7 +275,7 @@ static inline s64 ktime_to_ns(const ktime_t kt) | |||
275 | return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec; | 275 | return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec; |
276 | } | 276 | } |
277 | 277 | ||
278 | #endif | 278 | #endif /* !((BITS_PER_LONG == 64) || defined(CONFIG_KTIME_SCALAR)) */ |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * ktime_equal - Compares two ktime_t variables to see if they are equal | 281 | * ktime_equal - Compares two ktime_t variables to see if they are equal |
@@ -295,6 +295,12 @@ static inline s64 ktime_to_us(const ktime_t kt) | |||
295 | return (s64) tv.tv_sec * USEC_PER_SEC + tv.tv_usec; | 295 | return (s64) tv.tv_sec * USEC_PER_SEC + tv.tv_usec; |
296 | } | 296 | } |
297 | 297 | ||
298 | static inline s64 ktime_to_ms(const ktime_t kt) | ||
299 | { | ||
300 | struct timeval tv = ktime_to_timeval(kt); | ||
301 | return (s64) tv.tv_sec * MSEC_PER_SEC + tv.tv_usec / USEC_PER_MSEC; | ||
302 | } | ||
303 | |||
298 | static inline s64 ktime_us_delta(const ktime_t later, const ktime_t earlier) | 304 | static inline s64 ktime_us_delta(const ktime_t later, const ktime_t earlier) |
299 | { | 305 | { |
300 | return ktime_to_us(ktime_sub(later, earlier)); | 306 | return ktime_to_us(ktime_sub(later, earlier)); |