diff options
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r-- | include/linux/ktime.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 62bc5758070..84eeecd60a0 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
@@ -56,7 +56,8 @@ typedef union { | |||
56 | #endif | 56 | #endif |
57 | } ktime_t; | 57 | } ktime_t; |
58 | 58 | ||
59 | #define KTIME_MAX (~((u64)1 << 63)) | 59 | #define KTIME_MAX ((s64)~((u64)1 << 63)) |
60 | #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) | ||
60 | 61 | ||
61 | /* | 62 | /* |
62 | * ktime_t definitions when using the 64-bit scalar representation: | 63 | * ktime_t definitions when using the 64-bit scalar representation: |
@@ -66,7 +67,6 @@ typedef union { | |||
66 | 67 | ||
67 | /** | 68 | /** |
68 | * ktime_set - Set a ktime_t variable from a seconds/nanoseconds value | 69 | * ktime_set - Set a ktime_t variable from a seconds/nanoseconds value |
69 | * | ||
70 | * @secs: seconds to set | 70 | * @secs: seconds to set |
71 | * @nsecs: nanoseconds to set | 71 | * @nsecs: nanoseconds to set |
72 | * | 72 | * |
@@ -74,6 +74,10 @@ typedef union { | |||
74 | */ | 74 | */ |
75 | static inline ktime_t ktime_set(const long secs, const unsigned long nsecs) | 75 | static inline ktime_t ktime_set(const long secs, const unsigned long nsecs) |
76 | { | 76 | { |
77 | #if (BITS_PER_LONG == 64) | ||
78 | if (unlikely(secs >= KTIME_SEC_MAX)) | ||
79 | return (ktime_t){ .tv64 = KTIME_MAX }; | ||
80 | #endif | ||
77 | return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs }; | 81 | return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs }; |
78 | } | 82 | } |
79 | 83 | ||
@@ -138,7 +142,6 @@ static inline ktime_t ktime_set(const long secs, const unsigned long nsecs) | |||
138 | 142 | ||
139 | /** | 143 | /** |
140 | * ktime_sub - subtract two ktime_t variables | 144 | * ktime_sub - subtract two ktime_t variables |
141 | * | ||
142 | * @lhs: minuend | 145 | * @lhs: minuend |
143 | * @rhs: subtrahend | 146 | * @rhs: subtrahend |
144 | * | 147 | * |
@@ -157,7 +160,6 @@ static inline ktime_t ktime_sub(const ktime_t lhs, const ktime_t rhs) | |||
157 | 160 | ||
158 | /** | 161 | /** |
159 | * ktime_add - add two ktime_t variables | 162 | * ktime_add - add two ktime_t variables |
160 | * | ||
161 | * @add1: addend1 | 163 | * @add1: addend1 |
162 | * @add2: addend2 | 164 | * @add2: addend2 |
163 | * | 165 | * |
@@ -184,7 +186,6 @@ static inline ktime_t ktime_add(const ktime_t add1, const ktime_t add2) | |||
184 | 186 | ||
185 | /** | 187 | /** |
186 | * ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable | 188 | * ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable |
187 | * | ||
188 | * @kt: addend | 189 | * @kt: addend |
189 | * @nsec: the scalar nsec value to add | 190 | * @nsec: the scalar nsec value to add |
190 | * | 191 | * |
@@ -194,7 +195,6 @@ extern ktime_t ktime_add_ns(const ktime_t kt, u64 nsec); | |||
194 | 195 | ||
195 | /** | 196 | /** |
196 | * timespec_to_ktime - convert a timespec to ktime_t format | 197 | * timespec_to_ktime - convert a timespec to ktime_t format |
197 | * | ||
198 | * @ts: the timespec variable to convert | 198 | * @ts: the timespec variable to convert |
199 | * | 199 | * |
200 | * Returns a ktime_t variable with the converted timespec value | 200 | * Returns a ktime_t variable with the converted timespec value |
@@ -207,7 +207,6 @@ static inline ktime_t timespec_to_ktime(const struct timespec ts) | |||
207 | 207 | ||
208 | /** | 208 | /** |
209 | * timeval_to_ktime - convert a timeval to ktime_t format | 209 | * timeval_to_ktime - convert a timeval to ktime_t format |
210 | * | ||
211 | * @tv: the timeval variable to convert | 210 | * @tv: the timeval variable to convert |
212 | * | 211 | * |
213 | * Returns a ktime_t variable with the converted timeval value | 212 | * Returns a ktime_t variable with the converted timeval value |
@@ -220,7 +219,6 @@ static inline ktime_t timeval_to_ktime(const struct timeval tv) | |||
220 | 219 | ||
221 | /** | 220 | /** |
222 | * ktime_to_timespec - convert a ktime_t variable to timespec format | 221 | * ktime_to_timespec - convert a ktime_t variable to timespec format |
223 | * | ||
224 | * @kt: the ktime_t variable to convert | 222 | * @kt: the ktime_t variable to convert |
225 | * | 223 | * |
226 | * Returns the timespec representation of the ktime value | 224 | * Returns the timespec representation of the ktime value |
@@ -233,7 +231,6 @@ static inline struct timespec ktime_to_timespec(const ktime_t kt) | |||
233 | 231 | ||
234 | /** | 232 | /** |
235 | * ktime_to_timeval - convert a ktime_t variable to timeval format | 233 | * ktime_to_timeval - convert a ktime_t variable to timeval format |
236 | * | ||
237 | * @kt: the ktime_t variable to convert | 234 | * @kt: the ktime_t variable to convert |
238 | * | 235 | * |
239 | * Returns the timeval representation of the ktime value | 236 | * Returns the timeval representation of the ktime value |