aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/time.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2006-10-02 11:54:48 -0400
committerRalf Baechle <ralf@linux-mips.org>2006-10-03 12:59:18 -0400
commit8db0201026fbb45c383176f539dc8af2a6871ab8 (patch)
treeea8b3810d13f1e92f00f7e6a4a8cd0a617675011 /arch/mips/kernel/time.c
parent3f821640341b86e47b79122d92af365fc99b5d65 (diff)
[MIPS] Fix wreckage after removal of tickadj; convert to GENERIC_TIME.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/time.c')
-rw-r--r--arch/mips/kernel/time.c74
1 files changed, 0 insertions, 74 deletions
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 845c7e55505d..a8340802f2d7 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -149,80 +149,6 @@ void (*mips_timer_ack)(void);
149unsigned int (*mips_hpt_read)(void); 149unsigned int (*mips_hpt_read)(void);
150void (*mips_hpt_init)(unsigned int); 150void (*mips_hpt_init)(unsigned int);
151 151
152
153/*
154 * This version of gettimeofday has microsecond resolution and better than
155 * microsecond precision on fast machines with cycle counter.
156 */
157void do_gettimeofday(struct timeval *tv)
158{
159 unsigned long seq;
160 unsigned long usec, sec;
161 unsigned long max_ntp_tick;
162
163 do {
164 seq = read_seqbegin(&xtime_lock);
165
166 usec = do_gettimeoffset();
167
168 /*
169 * If time_adjust is negative then NTP is slowing the clock
170 * so make sure not to go into next possible interval.
171 * Better to lose some accuracy than have time go backwards..
172 */
173 if (unlikely(time_adjust < 0)) {
174 max_ntp_tick = (USEC_PER_SEC / HZ) - tickadj;
175 usec = min(usec, max_ntp_tick);
176 }
177
178 sec = xtime.tv_sec;
179 usec += (xtime.tv_nsec / 1000);
180
181 } while (read_seqretry(&xtime_lock, seq));
182
183 while (usec >= 1000000) {
184 usec -= 1000000;
185 sec++;
186 }
187
188 tv->tv_sec = sec;
189 tv->tv_usec = usec;
190}
191
192EXPORT_SYMBOL(do_gettimeofday);
193
194int do_settimeofday(struct timespec *tv)
195{
196 time_t wtm_sec, sec = tv->tv_sec;
197 long wtm_nsec, nsec = tv->tv_nsec;
198
199 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
200 return -EINVAL;
201
202 write_seqlock_irq(&xtime_lock);
203
204 /*
205 * This is revolting. We need to set "xtime" correctly. However,
206 * the value in this location is the value at the most recent update
207 * of wall time. Discover what correction gettimeofday() would have
208 * made, and then undo it!
209 */
210 nsec -= do_gettimeoffset() * NSEC_PER_USEC;
211
212 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
213 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
214
215 set_normalized_timespec(&xtime, sec, nsec);
216 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
217
218 ntp_clear();
219 write_sequnlock_irq(&xtime_lock);
220 clock_was_set();
221 return 0;
222}
223
224EXPORT_SYMBOL(do_settimeofday);
225
226/* 152/*
227 * Gettimeoffset routines. These routines returns the time duration 153 * Gettimeoffset routines. These routines returns the time duration
228 * since last timer interrupt in usecs. 154 * since last timer interrupt in usecs.