]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/time.c
[LLC]: Fix struct proto .name
[linux-2.6-omap-h63xx.git] / kernel / time.c
index 169e8329e0b63ba59ce29f438dd90f182280ce03..804539165d8b1aea0ea0dac3631377d7ae107f89 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <linux/module.h>
 #include <linux/timex.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/smp_lock.h>
 #include <linux/syscalls.h>
@@ -154,7 +155,7 @@ int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
        static int firsttime = 1;
        int error = 0;
 
-       if (!timespec_valid(tv))
+       if (tv && !timespec_valid(tv))
                return -EINVAL;
 
        error = security_settime(tv, tz);
@@ -636,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;
 }