aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohn stultz <johnstul@us.ibm.com>2009-09-16 00:17:19 -0400
committerMike Frysinger <vapier@gentoo.org>2009-10-07 04:36:20 -0400
commit10f03f1a249df01ec760e3494298510efad3271f (patch)
treec2558955c9b51834648887828d9ecfe0f3a74527
parent0eca52a92735f43462165efe00a7e394345fb38e (diff)
Blackfin: convert to use arch_gettimeoffset()
Convert Blackfin to use GENERIC_TIME via the arch_getoffset() infrastructure, reducing the amount of arch specific code we need to maintain. I've taken my best swing at converting this, but I'm not 100% confident I got it right. My cross-compiler is now out of date (gcc4.2) so I wasn't able to check if it compiled. Any assistance from arch maintainers or testers to get this merged would be great. Signed-off-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--arch/blackfin/Kconfig10
-rw-r--r--arch/blackfin/kernel/time.c63
2 files changed, 8 insertions, 65 deletions
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 9a01d445eca8..e51988237d3b 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -229,7 +229,7 @@ endchoice
229 229
230config SMP 230config SMP
231 depends on BF561 231 depends on BF561
232 select GENERIC_TIME 232 select GENERIC_CLOCKEVENTS
233 bool "Symmetric multi-processing support" 233 bool "Symmetric multi-processing support"
234 ---help--- 234 ---help---
235 This enables support for systems with more than one CPU, 235 This enables support for systems with more than one CPU,
@@ -613,12 +613,10 @@ comment "Kernel Timer/Scheduler"
613source kernel/Kconfig.hz 613source kernel/Kconfig.hz
614 614
615config GENERIC_TIME 615config GENERIC_TIME
616 bool "Generic time" 616 def_bool y
617 default y
618 617
619config GENERIC_CLOCKEVENTS 618config GENERIC_CLOCKEVENTS
620 bool "Generic clock events" 619 bool "Generic clock events"
621 depends on GENERIC_TIME
622 default y 620 default y
623 621
624choice 622choice
@@ -653,6 +651,10 @@ config GPTMR0_CLOCKSOURCE
653 depends on GENERIC_CLOCKEVENTS 651 depends on GENERIC_CLOCKEVENTS
654 depends on !TICKSOURCE_GPTMR0 652 depends on !TICKSOURCE_GPTMR0
655 653
654config ARCH_USES_GETTIMEOFFSET
655 depends on !GENERIC_CLOCKEVENTS
656 def_bool y
657
656source kernel/time/Kconfig 658source kernel/time/Kconfig
657 659
658comment "Misc" 660comment "Misc"
diff --git a/arch/blackfin/kernel/time.c b/arch/blackfin/kernel/time.c
index adb54aa7d7c8..e5069fe6861e 100644
--- a/arch/blackfin/kernel/time.c
+++ b/arch/blackfin/kernel/time.c
@@ -81,11 +81,11 @@ time_sched_init(irqreturn_t(*timer_routine) (int, void *))
81#endif 81#endif
82} 82}
83 83
84#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
84/* 85/*
85 * Should return useconds since last timer tick 86 * Should return useconds since last timer tick
86 */ 87 */
87#ifndef CONFIG_GENERIC_TIME 88u32 arch_gettimeoffset(void)
88static unsigned long gettimeoffset(void)
89{ 89{
90 unsigned long offset; 90 unsigned long offset;
91 unsigned long clocks_per_jiffy; 91 unsigned long clocks_per_jiffy;
@@ -184,65 +184,6 @@ void __init time_init(void)
184 time_sched_init(timer_interrupt); 184 time_sched_init(timer_interrupt);
185} 185}
186 186
187#ifndef CONFIG_GENERIC_TIME
188void 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}
210EXPORT_SYMBOL(do_gettimeofday);
211
212int 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}
243EXPORT_SYMBOL(do_settimeofday);
244#endif /* !CONFIG_GENERIC_TIME */
245
246/* 187/*
247 * Scheduler clock - returns current time in nanosec units. 188 * Scheduler clock - returns current time in nanosec units.
248 */ 189 */