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

ARM: local timers: introduce a new registration interface

In order to switch to a runtime selectable local timer,
add a registration interface that timer drivers can use to
register to the core.

local_timer_setup() and local_timer_stop() are made weak symbols
in order not to break existing setups.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

+42
+15
arch/arm/include/asm/localtimer.h
··· 15 15 16 16 struct clock_event_device; 17 17 18 + struct local_timer_ops { 19 + int (*setup)(struct clock_event_device *); 20 + void (*stop)(struct clock_event_device *); 21 + }; 22 + 18 23 /* 19 24 * Setup a per-cpu timer, whether it be a local timer or dummy broadcast 20 25 */ ··· 43 38 */ 44 39 int local_timer_setup(struct clock_event_device *); 45 40 41 + /* 42 + * Register a local timer driver 43 + */ 44 + int local_timer_register(struct local_timer_ops *); 45 + 46 46 #else 47 47 48 48 static inline int local_timer_setup(struct clock_event_device *evt) ··· 57 47 58 48 static inline void local_timer_stop(struct clock_event_device *evt) 59 49 { 50 + } 51 + 52 + static inline int local_timer_register(struct local_timer_ops *ops) 53 + { 54 + return -ENXIO; 60 55 } 61 56 #endif 62 57
+27
arch/arm/kernel/smp.c
··· 459 459 clockevents_register_device(evt); 460 460 } 461 461 462 + static struct local_timer_ops *lt_ops; 463 + 464 + #ifdef CONFIG_LOCAL_TIMERS 465 + int local_timer_register(struct local_timer_ops *ops) 466 + { 467 + if (lt_ops) 468 + return -EBUSY; 469 + 470 + lt_ops = ops; 471 + return 0; 472 + } 473 + #endif 474 + 475 + int __cpuinit __attribute__ ((weak)) local_timer_setup(struct clock_event_device *clk) 476 + { 477 + if (lt_ops) 478 + return lt_ops->setup(clk); 479 + 480 + return -ENXIO; 481 + } 482 + 483 + void __attribute__ ((weak)) local_timer_stop(struct clock_event_device *clk) 484 + { 485 + if (lt_ops) 486 + lt_ops->stop(clk); 487 + } 488 + 462 489 void __cpuinit percpu_timer_setup(void) 463 490 { 464 491 unsigned int cpu = smp_processor_id();