diff options
Diffstat (limited to 'arch/blackfin/kernel/time.c')
-rw-r--r-- | arch/blackfin/kernel/time.c | 64 |
1 files changed, 3 insertions, 61 deletions
diff --git a/arch/blackfin/kernel/time.c b/arch/blackfin/kernel/time.c index adb54aa7d7c8..bd3b53da295e 100644 --- a/arch/blackfin/kernel/time.c +++ b/arch/blackfin/kernel/time.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/time.h> | 14 | #include <linux/time.h> |
15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
16 | #include <linux/delay.h> | 16 | #include <linux/delay.h> |
17 | #include <linux/sched.h> | ||
17 | 18 | ||
18 | #include <asm/blackfin.h> | 19 | #include <asm/blackfin.h> |
19 | #include <asm/time.h> | 20 | #include <asm/time.h> |
@@ -81,11 +82,11 @@ time_sched_init(irqreturn_t(*timer_routine) (int, void *)) | |||
81 | #endif | 82 | #endif |
82 | } | 83 | } |
83 | 84 | ||
85 | #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET | ||
84 | /* | 86 | /* |
85 | * Should return useconds since last timer tick | 87 | * Should return useconds since last timer tick |
86 | */ | 88 | */ |
87 | #ifndef CONFIG_GENERIC_TIME | 89 | u32 arch_gettimeoffset(void) |
88 | static unsigned long gettimeoffset(void) | ||
89 | { | 90 | { |
90 | unsigned long offset; | 91 | unsigned long offset; |
91 | unsigned long clocks_per_jiffy; | 92 | unsigned long clocks_per_jiffy; |
@@ -184,65 +185,6 @@ void __init time_init(void) | |||
184 | time_sched_init(timer_interrupt); | 185 | time_sched_init(timer_interrupt); |
185 | } | 186 | } |
186 | 187 | ||
187 | #ifndef CONFIG_GENERIC_TIME | ||
188 | void do_gettimeofday(struct timeval *tv) | ||
189 | { | ||
190 | unsigned long flags; | ||
191 | unsigned long seq; | ||
192 | unsigned long usec, sec; | ||
193 | |||
194 | do { | ||
195 | seq = read_seqbegin_irqsave(&xtime_lock, flags); | ||
196 | usec = gettimeoffset(); | ||
197 | sec = xtime.tv_sec; | ||
198 | usec += (xtime.tv_nsec / NSEC_PER_USEC); | ||
199 | } | ||
200 | while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); | ||
201 | |||
202 | while (usec >= USEC_PER_SEC) { | ||
203 | usec -= USEC_PER_SEC; | ||
204 | sec++; | ||
205 | } | ||
206 | |||
207 | tv->tv_sec = sec; | ||
208 | tv->tv_usec = usec; | ||
209 | } | ||
210 | EXPORT_SYMBOL(do_gettimeofday); | ||
211 | |||
212 | int do_settimeofday(struct timespec *tv) | ||
213 | { | ||
214 | time_t wtm_sec, sec = tv->tv_sec; | ||
215 | long wtm_nsec, nsec = tv->tv_nsec; | ||
216 | |||
217 | if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC) | ||
218 | return -EINVAL; | ||
219 | |||
220 | write_seqlock_irq(&xtime_lock); | ||
221 | /* | ||
222 | * This is revolting. We need to set the xtime.tv_usec | ||
223 | * correctly. However, the value in this location is | ||
224 | * is value at the last tick. | ||
225 | * Discover what correction gettimeofday | ||
226 | * would have done, and then undo it! | ||
227 | */ | ||
228 | nsec -= (gettimeoffset() * NSEC_PER_USEC); | ||
229 | |||
230 | wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); | ||
231 | wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); | ||
232 | |||
233 | set_normalized_timespec(&xtime, sec, nsec); | ||
234 | set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec); | ||
235 | |||
236 | ntp_clear(); | ||
237 | |||
238 | write_sequnlock_irq(&xtime_lock); | ||
239 | clock_was_set(); | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | EXPORT_SYMBOL(do_settimeofday); | ||
244 | #endif /* !CONFIG_GENERIC_TIME */ | ||
245 | |||
246 | /* | 188 | /* |
247 | * Scheduler clock - returns current time in nanosec units. | 189 | * Scheduler clock - returns current time in nanosec units. |
248 | */ | 190 | */ |