summaryrefslogtreecommitdiffstats
path: root/kernel/time.c
diff options
context:
space:
mode:
authorGeorge Anzinger <george@wildturkeyranch.net>2006-02-03 12:04:20 +0100
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-03 17:32:06 +0100
commit88fc3897e3219e63ae6e2d180a6c87d033ef9f3b (patch)
tree4443e273b15c2f07229d65b90df2ae3579afb80d /kernel/time.c
parent[PATCH] v9fs: fix corner cases when flushing request (diff)
downloadlinux-88fc3897e3219e63ae6e2d180a6c87d033ef9f3b.tar.xz
linux-88fc3897e3219e63ae6e2d180a6c87d033ef9f3b.zip
[PATCH] Normalize timespec for negative values in ns_to_timespec
- In case of a negative nsec value the result of the division must be normalized. - Remove inline from an exported function. Signed-off-by: George Anzinger <george@wildturkeyranch.net> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/time.c')
-rw-r--r--kernel/time.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/kernel/time.c b/kernel/time.c
index 1f23e683d6aa..804539165d8b 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -637,15 +637,16 @@ void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec)
*
* Returns the timespec representation of the nsec parameter.
*/
-inline struct timespec ns_to_timespec(const nsec_t nsec)
+struct timespec ns_to_timespec(const nsec_t nsec)
{
struct timespec ts;
- if (nsec)
- ts.tv_sec = div_long_long_rem_signed(nsec, NSEC_PER_SEC,
- &ts.tv_nsec);
- else
- ts.tv_sec = ts.tv_nsec = 0;
+ if (!nsec)
+ return (struct timespec) {0, 0};
+
+ ts.tv_sec = div_long_long_rem_signed(nsec, NSEC_PER_SEC, &ts.tv_nsec);
+ if (unlikely(nsec < 0))
+ set_normalized_timespec(&ts, ts.tv_sec, ts.tv_nsec);
return ts;
}