Commit b11c4177 authored by Russell King's avatar Russell King

[ARM] Fix do_settimeofday()

ARM seems to have missed an update for the time keeping code; this
cset fixes a problem where the altering the system time changes the
reported uptime.
parent 6f461593
...@@ -174,6 +174,9 @@ void do_gettimeofday(struct timeval *tv) ...@@ -174,6 +174,9 @@ void do_gettimeofday(struct timeval *tv)
int do_settimeofday(struct timespec *tv) int do_settimeofday(struct timespec *tv)
{ {
time_t wtm_sec, sec = tv->tv_sec;
long wtm_nsec, nsec = tv->tv_nsec;
if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
return -EINVAL; return -EINVAL;
...@@ -184,21 +187,21 @@ int do_settimeofday(struct timespec *tv) ...@@ -184,21 +187,21 @@ int do_settimeofday(struct timespec *tv)
* wall time. Discover what correction gettimeofday() would have * wall time. Discover what correction gettimeofday() would have
* done, and then undo it! * done, and then undo it!
*/ */
tv->tv_nsec -= 1000 * (gettimeoffset() + nsec -= gettimeoffset() * NSEC_PER_USEC;
(jiffies - wall_jiffies) * USECS_PER_JIFFY); nsec -= (jiffies - wall_jiffies) * TICK_NSEC;
while (tv->tv_nsec < 0) { wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
tv->tv_nsec += NSEC_PER_SEC; wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
tv->tv_sec--;
} set_normalized_timespec(&xtime, sec, nsec);
set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
xtime.tv_sec = tv->tv_sec;
xtime.tv_nsec = tv->tv_nsec;
time_adjust = 0; /* stop active adjtime() */ time_adjust = 0; /* stop active adjtime() */
time_status |= STA_UNSYNC; time_status |= STA_UNSYNC;
time_maxerror = NTP_PHASE_LIMIT; time_maxerror = NTP_PHASE_LIMIT;
time_esterror = NTP_PHASE_LIMIT; time_esterror = NTP_PHASE_LIMIT;
write_sequnlock_irq(&xtime_lock); write_sequnlock_irq(&xtime_lock);
clock_was_set();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment