This patch lets timer callback functions have their natural type
(ie. exactly match the data pointer type); it allows the old "unsigned
long data" type as well.

Downside: if you use the old "unsigned long" callback type, you won't
get a warning if your data is not an unsigned long, due to the cast.

Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
---
 include/linux/timer.h |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff -r c53eb02af893 include/linux/timer.h
--- a/include/linux/timer.h     Thu Jan 31 17:27:22 2008 +1100
+++ b/include/linux/timer.h     Thu Jan 31 17:27:39 2008 +1100
@@ -24,11 +24,13 @@ struct timer_list {
 
 extern struct tvec_base boot_tvec_bases;
 
-#define TIMER_INITIALIZER(_function, _expires, _data) {                \
-               .function = (_function),                        \
-               .expires = (_expires),                          \
-               .data = (_data),                                \
-               .base = &boot_tvec_bases,                       \
+
+#define TIMER_INITIALIZER(_function, _expires, _data) {                        
\
+               .function = cast_if_type(_function, void (*)(typeof(_data)), \
+                                        void (*)(unsigned long)),      \
+               .expires = (_expires),                                  \
+               .data = (unsigned long)(_data),                         \
+               .base = &boot_tvec_bases,                               \
        }
 
 #define DEFINE_TIMER(_name, _function, _expires, _data)                \
@@ -38,9 +40,15 @@ void fastcall init_timer(struct timer_li
 void fastcall init_timer(struct timer_list * timer);
 void fastcall init_timer_deferrable(struct timer_list *timer);
 
-static inline void setup_timer(struct timer_list * timer,
-                               void (*function)(unsigned long),
-                               unsigned long data)
+#define setup_timer(timer, function, data)                             \
+       __setup_timer((timer),                                          \
+                     cast_if_type(function, void (*)(typeof(data)),    \
+                                  void (*)(unsigned long)),            \
+                     (unsigned long)(data))
+
+static inline void __setup_timer(struct timer_list * timer,
+                                void (*function)(unsigned long),
+                                unsigned long data)
 {
        timer->function = function;
        timer->data = data;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to