Commit 969c79c7 authored by David Mosberger's avatar David Mosberger

ia64: Fix settimeofday(). Based on patch by Eric Piel.

parent ebbece41
...@@ -60,7 +60,7 @@ do_profile (unsigned long ip) ...@@ -60,7 +60,7 @@ do_profile (unsigned long ip)
} }
/* /*
* Return the number of micro-seconds that elapsed since the last update to jiffy. The * Return the number of nano-seconds that elapsed since the last update to jiffy. The
* xtime_lock must be at least read-locked when calling this routine. * xtime_lock must be at least read-locked when calling this routine.
*/ */
static inline unsigned long static inline unsigned long
...@@ -86,6 +86,9 @@ gettimeoffset (void) ...@@ -86,6 +86,9 @@ gettimeoffset (void)
void void
do_settimeofday (struct timeval *tv) do_settimeofday (struct timeval *tv)
{ {
time_t sec = tv->tv_sec;
long nsec = tv->tv_usec * 1000;
write_seqlock_irq(&xtime_lock); write_seqlock_irq(&xtime_lock);
{ {
/* /*
...@@ -94,16 +97,16 @@ do_settimeofday (struct timeval *tv) ...@@ -94,16 +97,16 @@ do_settimeofday (struct timeval *tv)
* Discover what correction gettimeofday would have done, and then undo * Discover what correction gettimeofday would have done, and then undo
* it! * it!
*/ */
tv->tv_usec -= gettimeoffset(); nsec -= gettimeoffset();
tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ); nsec -= (jiffies - wall_jiffies ) * (1000000000 / HZ);
while (tv->tv_usec < 0) { while (nsec < 0) {
tv->tv_usec += 1000000; nsec += 1000000000;
tv->tv_sec--; sec--;
} }
xtime.tv_sec = tv->tv_sec; xtime.tv_sec = sec;
xtime.tv_nsec = 1000 * tv->tv_usec; xtime.tv_nsec = 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;
......
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