From 7b1f62076bba10786d2118006ae68ac120cd6c56 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 7 Nov 2012 17:58:54 -0700 Subject: time: convert arch_gettimeoffset to a pointer Currently, whenever CONFIG_ARCH_USES_GETTIMEOFFSET is enabled, each arch core provides a single implementation of arch_gettimeoffset(). In many cases, different sub-architectures, different machines, or different timer providers exist, and so the arch ends up implementing arch_gettimeoffset() as a call-through-pointer anyway. Examples are ARM, Cris, M68K, and it's arguable that the remaining architectures, M32R and Blackfin, should be doing this anyway. Modify arch_gettimeoffset so that it itself is a function pointer, which the arch initializes. This will allow later changes to move the initialization of this function into individual machine support or timer drivers. This is particularly useful for code in drivers/clocksource which should rely on an arch-independant mechanism to register their implementation of arch_gettimeoffset(). This patch also converts the Cris architecture to set arch_gettimeoffset directly to the final implementation in time_init(), because Cris already had separate time_init() functions per sub-architecture. M68K and ARM are converted to set arch_gettimeoffset to the final implementation in later patches, because they already have function pointers in place for this purpose. Cc: Russell King Cc: Mike Frysinger Cc: Mikael Starvik Cc: Hirokazu Takata Cc: Thomas Gleixner Acked-by: Geert Uytterhoeven Acked-by: Jesper Nilsson Acked-by: John Stultz Signed-off-by: Stephen Warren --- include/linux/time.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/include/linux/time.h b/include/linux/time.h index 4d358e9d10f1..05e32a72103c 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -142,9 +142,7 @@ void timekeeping_inject_sleeptime(struct timespec *delta); * finer then tick granular time. */ #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET -extern u32 arch_gettimeoffset(void); -#else -static inline u32 arch_gettimeoffset(void) { return 0; } +extern u32 (*arch_gettimeoffset)(void); #endif extern void do_gettimeofday(struct timeval *tv); -- cgit From 6bb27d7349db51b50c40534710fe164ca0d58902 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Thu, 8 Nov 2012 12:40:59 -0700 Subject: ARM: delete struct sys_timer Now that the only field in struct sys_timer is .init, delete the struct, and replace the machine descriptor .timer field with the initialization function itself. This will enable moving timer drivers into drivers/clocksource without having to place a public prototype of each struct sys_timer object into include/linux; the intent is to create a single of_clocksource_init() function that determines which timer driver to initialize by scanning the device dtree, much like the proposed irqchip_init() at: http://www.spinics.net/lists/arm-kernel/msg203686.html Includes mach-omap2 fixes from Igor Grinberg. Tested-by: Robert Jarzmik Signed-off-by: Stephen Warren --- include/linux/bcm2835_timer.h | 2 +- include/linux/dw_apb_timer.h | 2 +- include/linux/sunxi_timer.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/linux/bcm2835_timer.h b/include/linux/bcm2835_timer.h index 25680fe0903c..ca17aa817006 100644 --- a/include/linux/bcm2835_timer.h +++ b/include/linux/bcm2835_timer.h @@ -17,6 +17,6 @@ #include -extern struct sys_timer bcm2835_timer; +extern void bcm2835_timer_init(void); #endif diff --git a/include/linux/dw_apb_timer.h b/include/linux/dw_apb_timer.h index 1148575fd134..dd755ce2a5eb 100644 --- a/include/linux/dw_apb_timer.h +++ b/include/linux/dw_apb_timer.h @@ -53,5 +53,5 @@ void dw_apb_clocksource_start(struct dw_apb_clocksource *dw_cs); cycle_t dw_apb_clocksource_read(struct dw_apb_clocksource *dw_cs); void dw_apb_clocksource_unregister(struct dw_apb_clocksource *dw_cs); -extern struct sys_timer dw_apb_timer; +extern void dw_apb_timer_init(void); #endif /* __DW_APB_TIMER_H__ */ diff --git a/include/linux/sunxi_timer.h b/include/linux/sunxi_timer.h index b9165bba6e61..18081787e5f3 100644 --- a/include/linux/sunxi_timer.h +++ b/include/linux/sunxi_timer.h @@ -19,6 +19,6 @@ #include -extern struct sys_timer sunxi_timer; +void sunxi_timer_init(void); #endif -- cgit From ae278a935f086775e8ae31a8ec9f7224ea25ea3c Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 19 Nov 2012 16:41:20 -0700 Subject: clocksource: add common of_clksrc_init() function It is desirable to move all clocksource drivers to drivers/clocksource, yet each requires its own initialization function. We'd rather not pollute with a header for each function. Instead, create a single of_clksrc_init() function which will determine which clocksource driver to initialize based on device tree. Based on a similar patch for drivers/irqchip by Thomas Petazzoni. Signed-off-by: Stephen Warren --- include/asm-generic/vmlinux.lds.h | 9 +++++++++ include/linux/clocksource.h | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'include') diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index d1ea7ce0b4cb..1e744c5a0ffe 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -149,6 +149,14 @@ #define TRACE_SYSCALLS() #endif +#ifdef CONFIG_CLKSRC_OF +#define CLKSRC_OF_TABLES() . = ALIGN(8); \ + VMLINUX_SYMBOL(__clksrc_of_table) = .; \ + *(__clksrc_of_table) \ + *(__clksrc_of_table_end) +#else +#define CLKSRC_OF_TABLES() +#endif #define KERNEL_DTB() \ STRUCT_ALIGN(); \ @@ -493,6 +501,7 @@ DEV_DISCARD(init.rodata) \ CPU_DISCARD(init.rodata) \ MEM_DISCARD(init.rodata) \ + CLKSRC_OF_TABLES() \ KERNEL_DTB() #define INIT_TEXT \ diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 4dceaf8ae152..7944f14ea947 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h @@ -332,4 +332,13 @@ extern int clocksource_mmio_init(void __iomem *, const char *, extern int clocksource_i8253_init(void); +#ifdef CONFIG_CLKSRC_OF +extern void clocksource_of_init(void); + +#define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ + static const struct of_device_id __clksrc_of_table_##name \ + __used __section(__clksrc_of_table) \ + = { .compatible = compat, .data = fn }; +#endif + #endif /* _LINUX_CLOCKSOURCE_H */ -- cgit