aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/kernel/time_64.c
diff options
context:
space:
mode:
authorjohn stultz <johnstul@us.ibm.com>2009-05-01 16:10:28 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-05-03 04:32:55 -0400
commit7563431107f6debf57c1dbecfb9498cf31a1c036 (patch)
tree50e473f8eb90069b6e64675ee582dd3be76fbaef /arch/sh/kernel/time_64.c
parentd80498398276ca8eee7ebdbe0d47e06d01317439 (diff)
time: sh: convert to use arch_getoffset() infrastructure
Convert sh to use GENERIC_TIME via the arch_getoffset() infrastructure. Signed-off-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/time_64.c')
-rw-r--r--arch/sh/kernel/time_64.c53
1 files changed, 2 insertions, 51 deletions
diff --git a/arch/sh/kernel/time_64.c b/arch/sh/kernel/time_64.c
index 988c77c37231..f4f5e8ad5bec 100644
--- a/arch/sh/kernel/time_64.c
+++ b/arch/sh/kernel/time_64.c
@@ -144,59 +144,10 @@ static unsigned long usecs_since_tick(void)
144 return result; 144 return result;
145} 145}
146 146
147void do_gettimeofday(struct timeval *tv) 147u32 arch_gettimeoffset(void)
148{ 148{
149 unsigned long flags; 149 return usecs_since_tick() * 1000;
150 unsigned long seq;
151 unsigned long usec, sec;
152
153 do {
154 seq = read_seqbegin_irqsave(&xtime_lock, flags);
155 usec = usecs_since_tick();
156 sec = xtime.tv_sec;
157 usec += xtime.tv_nsec / 1000;
158 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
159
160 while (usec >= 1000000) {
161 usec -= 1000000;
162 sec++;
163 }
164
165 tv->tv_sec = sec;
166 tv->tv_usec = usec;
167}
168EXPORT_SYMBOL(do_gettimeofday);
169
170int do_settimeofday(struct timespec *tv)
171{
172 time_t wtm_sec, sec = tv->tv_sec;
173 long wtm_nsec, nsec = tv->tv_nsec;
174
175 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
176 return -EINVAL;
177
178 write_seqlock_irq(&xtime_lock);
179 /*
180 * This is revolting. We need to set "xtime" correctly. However, the
181 * value in this location is the value at the most recent update of
182 * wall time. Discover what correction gettimeofday() would have
183 * made, and then undo it!
184 */
185 nsec -= 1000 * usecs_since_tick();
186
187 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
188 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
189
190 set_normalized_timespec(&xtime, sec, nsec);
191 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
192
193 ntp_clear();
194 write_sequnlock_irq(&xtime_lock);
195 clock_was_set();
196
197 return 0;
198} 150}
199EXPORT_SYMBOL(do_settimeofday);
200 151
201/* Dummy RTC ops */ 152/* Dummy RTC ops */
202static void null_rtc_get_time(struct timespec *tv) 153static void null_rtc_get_time(struct timespec *tv)