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

clocksource: make CLOCKSOURCE_OF_DECLARE type safe

This ensures that a function pointer passed into CLOCKSOURCE_OF_DECLARE
takes the same arguments that we use for calling that function later.

Also fix the extraneous semicolon at end of the CLOCKSOURCE_OF_DECLARE
definition.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Rob Herring <rob.herring@calxeda.com>

+12 -4
+2 -1
drivers/clocksource/clksrc-of.c
··· 16 16 17 17 #include <linux/init.h> 18 18 #include <linux/of.h> 19 + #include <linux/clocksource.h> 19 20 20 21 extern struct of_device_id __clksrc_of_table[]; 21 22 ··· 27 26 { 28 27 struct device_node *np; 29 28 const struct of_device_id *match; 30 - void (*init_func)(struct device_node *); 29 + clocksource_of_init_fn init_func; 31 30 32 31 for_each_matching_node_and_match(np, __clksrc_of_table, &match) { 33 32 init_func = match->data;
+1 -1
drivers/clocksource/vt8500_timer.c
··· 165 165 4, 0xf0000000); 166 166 } 167 167 168 - CLOCKSOURCE_OF_DECLARE(vt8500, "via,vt8500-timer", vt8500_timer_init) 168 + CLOCKSOURCE_OF_DECLARE(vt8500, "via,vt8500-timer", vt8500_timer_init);
+9 -2
include/linux/clocksource.h
··· 332 332 333 333 extern int clocksource_i8253_init(void); 334 334 335 + struct device_node; 336 + typedef void(*clocksource_of_init_fn)(struct device_node *); 335 337 #ifdef CONFIG_CLKSRC_OF 336 338 extern void clocksource_of_init(void); 337 339 338 340 #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ 339 341 static const struct of_device_id __clksrc_of_table_##name \ 340 342 __used __section(__clksrc_of_table) \ 341 - = { .compatible = compat, .data = fn }; 343 + = { .compatible = compat, \ 344 + .data = (fn == (clocksource_of_init_fn)NULL) ? fn : fn } 342 345 #else 343 346 static inline void clocksource_of_init(void) {} 344 - #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) 347 + #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ 348 + static const struct of_device_id __clksrc_of_table_##name \ 349 + __attribute__((unused)) \ 350 + = { .compatible = compat, \ 351 + .data = (fn == (clocksource_of_init_fn)NULL) ? fn : fn } 345 352 #endif 346 353 347 354 #endif /* _LINUX_CLOCKSOURCE_H */