]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sh: fix do_settimeofday() for new API
authorAndrew Morton <akpm@digeo.com>
Sat, 14 Jun 2003 14:21:14 +0000 (07:21 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sat, 14 Jun 2003 14:21:14 +0000 (07:21 -0700)
arch/sh/kernel/time.c

index 3042f8483988340b8f10c76da256f4db106b5e69..c5b7604e9ae6b4bf3cf3b24250ed5403a4bd63b0 100644 (file)
@@ -151,8 +151,11 @@ void do_gettimeofday(struct timeval *tv)
        tv->tv_usec = usec;
 }
 
-void do_settimeofday(struct timeval *tv)
+int do_settimeofday(struct timespec *tv)
 {
+       if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
+               return -EINVAL;
+
        write_seqlock_irq(&xtime_lock);
        /*
         * This is revolting. We need to set "xtime" correctly. However, the
@@ -160,11 +163,11 @@ void do_settimeofday(struct timeval *tv)
         * wall time.  Discover what correction gettimeofday() would have
         * made, and then undo it!
         */
-       tv->tv_usec -= do_gettimeoffset();
-       tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ);
+       tv->tv_nsec -= 1000 * (do_gettimeoffset() +
+                               (jiffies - wall_jiffies) * (1000000 / HZ));
 
-       while (tv->tv_usec < 0) {
-               tv->tv_usec += 1000000;
+       while (tv->tv_nsec < 0) {
+               tv->tv_nsec += NSEC_PER_SEC;
                tv->tv_sec--;
        }
 
@@ -174,6 +177,7 @@ void do_settimeofday(struct timeval *tv)
        time_maxerror = NTP_PHASE_LIMIT;
        time_esterror = NTP_PHASE_LIMIT;
        write_sequnlock_irq(&xtime_lock);
+       return 0;
 }
 
 /* last time the RTC clock got updated */