diff options
Diffstat (limited to 'include/linux/timer.h')
| -rw-r--r-- | include/linux/timer.h | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/include/linux/timer.h b/include/linux/timer.h index ac66f29c6916..bf781acfc6d8 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h | |||
| @@ -64,31 +64,21 @@ struct timer_list { | |||
| 64 | 64 | ||
| 65 | #define TIMER_TRACE_FLAGMASK (TIMER_MIGRATING | TIMER_DEFERRABLE | TIMER_PINNED | TIMER_IRQSAFE) | 65 | #define TIMER_TRACE_FLAGMASK (TIMER_MIGRATING | TIMER_DEFERRABLE | TIMER_PINNED | TIMER_IRQSAFE) |
| 66 | 66 | ||
| 67 | #define __TIMER_INITIALIZER(_function, _expires, _data, _flags) { \ | 67 | #define TIMER_DATA_TYPE unsigned long |
| 68 | #define TIMER_FUNC_TYPE void (*)(TIMER_DATA_TYPE) | ||
| 69 | |||
| 70 | #define __TIMER_INITIALIZER(_function, _data, _flags) { \ | ||
| 68 | .entry = { .next = TIMER_ENTRY_STATIC }, \ | 71 | .entry = { .next = TIMER_ENTRY_STATIC }, \ |
| 69 | .function = (_function), \ | 72 | .function = (_function), \ |
| 70 | .expires = (_expires), \ | ||
| 71 | .data = (_data), \ | 73 | .data = (_data), \ |
| 72 | .flags = (_flags), \ | 74 | .flags = (_flags), \ |
| 73 | __TIMER_LOCKDEP_MAP_INITIALIZER( \ | 75 | __TIMER_LOCKDEP_MAP_INITIALIZER( \ |
| 74 | __FILE__ ":" __stringify(__LINE__)) \ | 76 | __FILE__ ":" __stringify(__LINE__)) \ |
| 75 | } | 77 | } |
| 76 | 78 | ||
| 77 | #define TIMER_INITIALIZER(_function, _expires, _data) \ | 79 | #define DEFINE_TIMER(_name, _function) \ |
| 78 | __TIMER_INITIALIZER((_function), (_expires), (_data), 0) | ||
| 79 | |||
| 80 | #define TIMER_PINNED_INITIALIZER(_function, _expires, _data) \ | ||
| 81 | __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_PINNED) | ||
| 82 | |||
| 83 | #define TIMER_DEFERRED_INITIALIZER(_function, _expires, _data) \ | ||
| 84 | __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_DEFERRABLE) | ||
| 85 | |||
| 86 | #define TIMER_PINNED_DEFERRED_INITIALIZER(_function, _expires, _data) \ | ||
| 87 | __TIMER_INITIALIZER((_function), (_expires), (_data), TIMER_DEFERRABLE | TIMER_PINNED) | ||
| 88 | |||
| 89 | #define DEFINE_TIMER(_name, _function, _expires, _data) \ | ||
| 90 | struct timer_list _name = \ | 80 | struct timer_list _name = \ |
| 91 | TIMER_INITIALIZER(_function, _expires, _data) | 81 | __TIMER_INITIALIZER((TIMER_FUNC_TYPE)_function, 0, 0) |
| 92 | 82 | ||
| 93 | void init_timer_key(struct timer_list *timer, unsigned int flags, | 83 | void init_timer_key(struct timer_list *timer, unsigned int flags, |
| 94 | const char *name, struct lock_class_key *key); | 84 | const char *name, struct lock_class_key *key); |
| @@ -129,14 +119,6 @@ static inline void init_timer_on_stack_key(struct timer_list *timer, | |||
| 129 | 119 | ||
| 130 | #define init_timer(timer) \ | 120 | #define init_timer(timer) \ |
| 131 | __init_timer((timer), 0) | 121 | __init_timer((timer), 0) |
| 132 | #define init_timer_pinned(timer) \ | ||
| 133 | __init_timer((timer), TIMER_PINNED) | ||
| 134 | #define init_timer_deferrable(timer) \ | ||
| 135 | __init_timer((timer), TIMER_DEFERRABLE) | ||
| 136 | #define init_timer_pinned_deferrable(timer) \ | ||
| 137 | __init_timer((timer), TIMER_DEFERRABLE | TIMER_PINNED) | ||
| 138 | #define init_timer_on_stack(timer) \ | ||
| 139 | __init_timer_on_stack((timer), 0) | ||
| 140 | 122 | ||
| 141 | #define __setup_timer(_timer, _fn, _data, _flags) \ | 123 | #define __setup_timer(_timer, _fn, _data, _flags) \ |
| 142 | do { \ | 124 | do { \ |
| @@ -169,9 +151,7 @@ static inline void init_timer_on_stack_key(struct timer_list *timer, | |||
| 169 | #define setup_pinned_deferrable_timer_on_stack(timer, fn, data) \ | 151 | #define setup_pinned_deferrable_timer_on_stack(timer, fn, data) \ |
| 170 | __setup_timer_on_stack((timer), (fn), (data), TIMER_DEFERRABLE | TIMER_PINNED) | 152 | __setup_timer_on_stack((timer), (fn), (data), TIMER_DEFERRABLE | TIMER_PINNED) |
| 171 | 153 | ||
| 172 | #define TIMER_DATA_TYPE unsigned long | 154 | #ifndef CONFIG_LOCKDEP |
| 173 | #define TIMER_FUNC_TYPE void (*)(TIMER_DATA_TYPE) | ||
| 174 | |||
| 175 | static inline void timer_setup(struct timer_list *timer, | 155 | static inline void timer_setup(struct timer_list *timer, |
| 176 | void (*callback)(struct timer_list *), | 156 | void (*callback)(struct timer_list *), |
| 177 | unsigned int flags) | 157 | unsigned int flags) |
| @@ -180,6 +160,28 @@ static inline void timer_setup(struct timer_list *timer, | |||
| 180 | (TIMER_DATA_TYPE)timer, flags); | 160 | (TIMER_DATA_TYPE)timer, flags); |
| 181 | } | 161 | } |
| 182 | 162 | ||
| 163 | static inline void timer_setup_on_stack(struct timer_list *timer, | ||
| 164 | void (*callback)(struct timer_list *), | ||
| 165 | unsigned int flags) | ||
| 166 | { | ||
| 167 | __setup_timer_on_stack(timer, (TIMER_FUNC_TYPE)callback, | ||
| 168 | (TIMER_DATA_TYPE)timer, flags); | ||
| 169 | } | ||
| 170 | #else | ||
| 171 | /* | ||
| 172 | * Under LOCKDEP, the timer lock_class_key (set up in __init_timer) needs | ||
| 173 | * to be tied to the caller's context, so an inline (above) won't work. We | ||
| 174 | * do want to keep the inline for argument type checking, though. | ||
| 175 | */ | ||
| 176 | # define timer_setup(timer, callback, flags) \ | ||
| 177 | __setup_timer((timer), (TIMER_FUNC_TYPE)(callback), \ | ||
| 178 | (TIMER_DATA_TYPE)(timer), (flags)) | ||
| 179 | # define timer_setup_on_stack(timer, callback, flags) \ | ||
| 180 | __setup_timer_on_stack((timer), \ | ||
| 181 | (TIMER_FUNC_TYPE)(callback), \ | ||
| 182 | (TIMER_DATA_TYPE)(timer), (flags)) | ||
| 183 | #endif | ||
| 184 | |||
| 183 | #define from_timer(var, callback_timer, timer_fieldname) \ | 185 | #define from_timer(var, callback_timer, timer_fieldname) \ |
| 184 | container_of(callback_timer, typeof(*var), timer_fieldname) | 186 | container_of(callback_timer, typeof(*var), timer_fieldname) |
| 185 | 187 | ||
| @@ -202,6 +204,7 @@ extern void add_timer_on(struct timer_list *timer, int cpu); | |||
| 202 | extern int del_timer(struct timer_list * timer); | 204 | extern int del_timer(struct timer_list * timer); |
| 203 | extern int mod_timer(struct timer_list *timer, unsigned long expires); | 205 | extern int mod_timer(struct timer_list *timer, unsigned long expires); |
| 204 | extern int mod_timer_pending(struct timer_list *timer, unsigned long expires); | 206 | extern int mod_timer_pending(struct timer_list *timer, unsigned long expires); |
| 207 | extern int timer_reduce(struct timer_list *timer, unsigned long expires); | ||
| 205 | 208 | ||
| 206 | /* | 209 | /* |
| 207 | * The jiffies value which is added to now, when there is no timer | 210 | * The jiffies value which is added to now, when there is no timer |
