diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2007-08-19 20:16:05 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:48:12 -0400 |
commit | a272378d1128d1c60a463a315646c86d174ff74c (patch) | |
tree | f583426e350d48b216f1e09adcc01522bcc8adc9 /kernel | |
parent | e7a81c6d62cbefdeb23d92ad891f429bde1c49d2 (diff) |
[KTIME]: Introduce ktime_sub_ns and ktime_sub_us
First user will be the DCCP transport networking protocol.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/hrtimer.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index c21ca6bfaa66..dc8a4451d79b 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -277,6 +277,30 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec) | |||
277 | } | 277 | } |
278 | 278 | ||
279 | EXPORT_SYMBOL_GPL(ktime_add_ns); | 279 | EXPORT_SYMBOL_GPL(ktime_add_ns); |
280 | |||
281 | /** | ||
282 | * ktime_sub_ns - Subtract a scalar nanoseconds value from a ktime_t variable | ||
283 | * @kt: minuend | ||
284 | * @nsec: the scalar nsec value to subtract | ||
285 | * | ||
286 | * Returns the subtraction of @nsec from @kt in ktime_t format | ||
287 | */ | ||
288 | ktime_t ktime_sub_ns(const ktime_t kt, u64 nsec) | ||
289 | { | ||
290 | ktime_t tmp; | ||
291 | |||
292 | if (likely(nsec < NSEC_PER_SEC)) { | ||
293 | tmp.tv64 = nsec; | ||
294 | } else { | ||
295 | unsigned long rem = do_div(nsec, NSEC_PER_SEC); | ||
296 | |||
297 | tmp = ktime_set((long)nsec, rem); | ||
298 | } | ||
299 | |||
300 | return ktime_sub(kt, tmp); | ||
301 | } | ||
302 | |||
303 | EXPORT_SYMBOL_GPL(ktime_sub_ns); | ||
280 | # endif /* !CONFIG_KTIME_SCALAR */ | 304 | # endif /* !CONFIG_KTIME_SCALAR */ |
281 | 305 | ||
282 | /* | 306 | /* |