Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

john stultz and committed by
Mike Frysinger
10f03f1a 0eca52a9

+8 -65
+6 -4
arch/blackfin/Kconfig
··· 229 229 230 230 config SMP 231 231 depends on BF561 232 - select GENERIC_TIME 232 + select GENERIC_CLOCKEVENTS 233 233 bool "Symmetric multi-processing support" 234 234 ---help--- 235 235 This enables support for systems with more than one CPU, ··· 613 613 source kernel/Kconfig.hz 614 614 615 615 config GENERIC_TIME 616 - bool "Generic time" 617 - default y 616 + def_bool y 618 617 619 618 config GENERIC_CLOCKEVENTS 620 619 bool "Generic clock events" 621 - depends on GENERIC_TIME 622 620 default y 623 621 624 622 choice ··· 650 652 select BFIN_GPTIMERS 651 653 depends on GENERIC_CLOCKEVENTS 652 654 depends on !TICKSOURCE_GPTMR0 655 + 656 + config ARCH_USES_GETTIMEOFFSET 657 + depends on !GENERIC_CLOCKEVENTS 658 + def_bool y 653 659 654 660 source kernel/time/Kconfig 655 661
+2 -61
arch/blackfin/kernel/time.c
··· 81 81 #endif 82 82 } 83 83 84 + #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET 84 85 /* 85 86 * Should return useconds since last timer tick 86 87 */ 87 - #ifndef CONFIG_GENERIC_TIME 88 - static unsigned long gettimeoffset(void) 88 + u32 arch_gettimeoffset(void) 89 89 { 90 90 unsigned long offset; 91 91 unsigned long clocks_per_jiffy; ··· 183 183 184 184 time_sched_init(timer_interrupt); 185 185 } 186 - 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 186 246 187 /* 247 188 * Scheduler clock - returns current time in nanosec units.