| .. | .. |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | #include <linux/time.h> |
|---|
| 25 | 25 | #include <linux/jiffies.h> |
|---|
| 26 | +#include <asm/bug.h> |
|---|
| 26 | 27 | |
|---|
| 27 | 28 | /* Nanosecond scalar representation for kernel time values */ |
|---|
| 28 | 29 | typedef s64 ktime_t; |
|---|
| .. | .. |
|---|
| 66 | 67 | */ |
|---|
| 67 | 68 | #define ktime_sub_ns(kt, nsval) ((kt) - (nsval)) |
|---|
| 68 | 69 | |
|---|
| 69 | | -/* convert a timespec to ktime_t format: */ |
|---|
| 70 | | -static inline ktime_t timespec_to_ktime(struct timespec ts) |
|---|
| 71 | | -{ |
|---|
| 72 | | - return ktime_set(ts.tv_sec, ts.tv_nsec); |
|---|
| 73 | | -} |
|---|
| 74 | | - |
|---|
| 75 | 70 | /* convert a timespec64 to ktime_t format: */ |
|---|
| 76 | 71 | static inline ktime_t timespec64_to_ktime(struct timespec64 ts) |
|---|
| 77 | 72 | { |
|---|
| 78 | 73 | return ktime_set(ts.tv_sec, ts.tv_nsec); |
|---|
| 79 | 74 | } |
|---|
| 80 | 75 | |
|---|
| 81 | | -/* convert a timeval to ktime_t format: */ |
|---|
| 82 | | -static inline ktime_t timeval_to_ktime(struct timeval tv) |
|---|
| 83 | | -{ |
|---|
| 84 | | - return ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC); |
|---|
| 85 | | -} |
|---|
| 86 | | - |
|---|
| 87 | | -/* Map the ktime_t to timespec conversion to ns_to_timespec function */ |
|---|
| 88 | | -#define ktime_to_timespec(kt) ns_to_timespec((kt)) |
|---|
| 89 | | - |
|---|
| 90 | 76 | /* Map the ktime_t to timespec conversion to ns_to_timespec function */ |
|---|
| 91 | 77 | #define ktime_to_timespec64(kt) ns_to_timespec64((kt)) |
|---|
| 92 | | - |
|---|
| 93 | | -/* Map the ktime_t to timeval conversion to ns_to_timeval function */ |
|---|
| 94 | | -#define ktime_to_timeval(kt) ns_to_timeval((kt)) |
|---|
| 95 | 78 | |
|---|
| 96 | 79 | /* Convert ktime_t to nanoseconds */ |
|---|
| 97 | 80 | static inline s64 ktime_to_ns(const ktime_t kt) |
|---|
| .. | .. |
|---|
| 214 | 197 | } |
|---|
| 215 | 198 | |
|---|
| 216 | 199 | extern ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs); |
|---|
| 217 | | - |
|---|
| 218 | | -/** |
|---|
| 219 | | - * ktime_to_timespec_cond - convert a ktime_t variable to timespec |
|---|
| 220 | | - * format only if the variable contains data |
|---|
| 221 | | - * @kt: the ktime_t variable to convert |
|---|
| 222 | | - * @ts: the timespec variable to store the result in |
|---|
| 223 | | - * |
|---|
| 224 | | - * Return: %true if there was a successful conversion, %false if kt was 0. |
|---|
| 225 | | - */ |
|---|
| 226 | | -static inline __must_check bool ktime_to_timespec_cond(const ktime_t kt, |
|---|
| 227 | | - struct timespec *ts) |
|---|
| 228 | | -{ |
|---|
| 229 | | - if (kt) { |
|---|
| 230 | | - *ts = ktime_to_timespec(kt); |
|---|
| 231 | | - return true; |
|---|
| 232 | | - } else { |
|---|
| 233 | | - return false; |
|---|
| 234 | | - } |
|---|
| 235 | | -} |
|---|
| 236 | 200 | |
|---|
| 237 | 201 | /** |
|---|
| 238 | 202 | * ktime_to_timespec64_cond - convert a ktime_t variable to timespec64 |
|---|