diff options
| author | Kees Cook <keescook@chromium.org> | 2017-10-22 21:48:43 -0400 |
|---|---|---|
| committer | Kees Cook <keescook@chromium.org> | 2017-11-21 18:57:15 -0500 |
| commit | 919b250f8570618e84af544c3e18dad5210eb9b6 (patch) | |
| tree | 1d40f3839c10ee62e70b5db4ac5ba30aa3e4a1c0 | |
| parent | 188665b2d67db8953899551d1a9d4481b2a0ac60 (diff) | |
timer: Remove redundant __setup_timer*() macros
With __init_timer*() now matching __setup_timer*(), remove the redundant
internal interface, clean up the resulting definitions and add more
documentation.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tejun Heo <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: Shaohua Li <shli@fb.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
| -rw-r--r-- | include/linux/kthread.h | 6 | ||||
| -rw-r--r-- | include/linux/timer.h | 56 | ||||
| -rw-r--r-- | include/linux/workqueue.h | 12 |
3 files changed, 29 insertions, 45 deletions
diff --git a/include/linux/kthread.h b/include/linux/kthread.h index b855c5b72b26..dc850d257ea2 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h | |||
| @@ -164,9 +164,9 @@ extern void __kthread_init_worker(struct kthread_worker *worker, | |||
| 164 | #define kthread_init_delayed_work(dwork, fn) \ | 164 | #define kthread_init_delayed_work(dwork, fn) \ |
| 165 | do { \ | 165 | do { \ |
| 166 | kthread_init_work(&(dwork)->work, (fn)); \ | 166 | kthread_init_work(&(dwork)->work, (fn)); \ |
| 167 | __setup_timer(&(dwork)->timer, \ | 167 | __init_timer(&(dwork)->timer, \ |
| 168 | (TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\ | 168 | kthread_delayed_work_timer_fn, \ |
| 169 | TIMER_IRQSAFE); \ | 169 | TIMER_IRQSAFE); \ |
| 170 | } while (0) | 170 | } while (0) |
| 171 | 171 | ||
| 172 | int kthread_worker_fn(void *worker_ptr); | 172 | int kthread_worker_fn(void *worker_ptr); |
diff --git a/include/linux/timer.h b/include/linux/timer.h index aff73b1c8f7b..b1ae64b112c2 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h | |||
| @@ -78,6 +78,9 @@ struct timer_list { | |||
| 78 | struct timer_list _name = \ | 78 | struct timer_list _name = \ |
| 79 | __TIMER_INITIALIZER((TIMER_FUNC_TYPE)_function, 0) | 79 | __TIMER_INITIALIZER((TIMER_FUNC_TYPE)_function, 0) |
| 80 | 80 | ||
| 81 | /* | ||
| 82 | * LOCKDEP and DEBUG timer interfaces. | ||
| 83 | */ | ||
| 81 | void init_timer_key(struct timer_list *timer, | 84 | void init_timer_key(struct timer_list *timer, |
| 82 | void (*func)(struct timer_list *), unsigned int flags, | 85 | void (*func)(struct timer_list *), unsigned int flags, |
| 83 | const char *name, struct lock_class_key *key); | 86 | const char *name, struct lock_class_key *key); |
| @@ -87,9 +90,7 @@ extern void init_timer_on_stack_key(struct timer_list *timer, | |||
| 87 | void (*func)(struct timer_list *), | 90 | void (*func)(struct timer_list *), |
| 88 | unsigned int flags, const char *name, | 91 | unsigned int flags, const char *name, |
| 89 | struct lock_class_key *key); | 92 | struct lock_class_key *key); |
| 90 | extern void destroy_timer_on_stack(struct timer_list *timer); | ||
| 91 | #else | 93 | #else |
| 92 | static inline void destroy_timer_on_stack(struct timer_list *timer) { } | ||
| 93 | static inline void init_timer_on_stack_key(struct timer_list *timer, | 94 | static inline void init_timer_on_stack_key(struct timer_list *timer, |
| 94 | void (*func)(struct timer_list *), | 95 | void (*func)(struct timer_list *), |
| 95 | unsigned int flags, | 96 | unsigned int flags, |
| @@ -120,43 +121,26 @@ static inline void init_timer_on_stack_key(struct timer_list *timer, | |||
| 120 | init_timer_on_stack_key((_timer), (_fn), (_flags), NULL, NULL) | 121 | init_timer_on_stack_key((_timer), (_fn), (_flags), NULL, NULL) |
| 121 | #endif | 122 | #endif |
| 122 | 123 | ||
| 123 | #define __setup_timer(_timer, _fn, _flags) \ | 124 | /** |
| 124 | do { \ | 125 | * timer_setup - prepare a timer for first use |
| 125 | __init_timer((_timer), (_fn), (_flags)); \ | 126 | * @timer: the timer in question |
| 126 | } while (0) | 127 | * @callback: the function to call when timer expires |
| 127 | 128 | * @flags: any TIMER_* flags | |
| 128 | #define __setup_timer_on_stack(_timer, _fn, _flags) \ | 129 | * |
| 129 | do { \ | 130 | * Regular timer initialization should use either DEFINE_TIMER() above, |
| 130 | __init_timer_on_stack((_timer), (_fn), (_flags)); \ | 131 | * or timer_setup(). For timers on the stack, timer_setup_on_stack() must |
| 131 | } while (0) | 132 | * be used and must be balanced with a call to destroy_timer_on_stack(). |
| 133 | */ | ||
| 134 | #define timer_setup(timer, callback, flags) \ | ||
| 135 | __init_timer((timer), (callback), (flags)) | ||
| 132 | 136 | ||
| 133 | #ifndef CONFIG_LOCKDEP | 137 | #define timer_setup_on_stack(timer, callback, flags) \ |
| 134 | static inline void timer_setup(struct timer_list *timer, | 138 | __init_timer_on_stack((timer), (callback), (flags)) |
| 135 | void (*callback)(struct timer_list *), | ||
| 136 | unsigned int flags) | ||
| 137 | { | ||
| 138 | __setup_timer(timer, (TIMER_FUNC_TYPE)callback, flags); | ||
| 139 | } | ||
| 140 | 139 | ||
| 141 | static inline void timer_setup_on_stack(struct timer_list *timer, | 140 | #ifdef CONFIG_DEBUG_OBJECTS_TIMERS |
| 142 | void (*callback)(struct timer_list *), | 141 | extern void destroy_timer_on_stack(struct timer_list *timer); |
| 143 | unsigned int flags) | ||
| 144 | { | ||
| 145 | __setup_timer_on_stack(timer, (TIMER_FUNC_TYPE)callback, flags); | ||
| 146 | } | ||
| 147 | #else | 142 | #else |
| 148 | /* | 143 | static inline void destroy_timer_on_stack(struct timer_list *timer) { } |
| 149 | * Under LOCKDEP, the timer lock_class_key (set up in __init_timer) needs | ||
| 150 | * to be tied to the caller's context, so an inline (above) won't work. We | ||
| 151 | * do want to keep the inline for argument type checking, though. | ||
| 152 | */ | ||
| 153 | # define timer_setup(timer, callback, flags) \ | ||
| 154 | __setup_timer((timer), (TIMER_FUNC_TYPE)(callback), \ | ||
| 155 | (flags)) | ||
| 156 | # define timer_setup_on_stack(timer, callback, flags) \ | ||
| 157 | __setup_timer_on_stack((timer), \ | ||
| 158 | (TIMER_FUNC_TYPE)(callback), \ | ||
| 159 | (flags)) | ||
| 160 | #endif | 144 | #endif |
| 161 | 145 | ||
| 162 | #define from_timer(var, callback_timer, timer_fieldname) \ | 146 | #define from_timer(var, callback_timer, timer_fieldname) \ |
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 8d11580237f5..bff39faba793 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h | |||
| @@ -241,17 +241,17 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; } | |||
| 241 | #define __INIT_DELAYED_WORK(_work, _func, _tflags) \ | 241 | #define __INIT_DELAYED_WORK(_work, _func, _tflags) \ |
| 242 | do { \ | 242 | do { \ |
| 243 | INIT_WORK(&(_work)->work, (_func)); \ | 243 | INIT_WORK(&(_work)->work, (_func)); \ |
| 244 | __setup_timer(&(_work)->timer, \ | 244 | __init_timer(&(_work)->timer, \ |
| 245 | (TIMER_FUNC_TYPE)delayed_work_timer_fn, \ | 245 | delayed_work_timer_fn, \ |
| 246 | (_tflags) | TIMER_IRQSAFE); \ | 246 | (_tflags) | TIMER_IRQSAFE); \ |
| 247 | } while (0) | 247 | } while (0) |
| 248 | 248 | ||
| 249 | #define __INIT_DELAYED_WORK_ONSTACK(_work, _func, _tflags) \ | 249 | #define __INIT_DELAYED_WORK_ONSTACK(_work, _func, _tflags) \ |
| 250 | do { \ | 250 | do { \ |
| 251 | INIT_WORK_ONSTACK(&(_work)->work, (_func)); \ | 251 | INIT_WORK_ONSTACK(&(_work)->work, (_func)); \ |
| 252 | __setup_timer_on_stack(&(_work)->timer, \ | 252 | __init_timer_on_stack(&(_work)->timer, \ |
| 253 | (TIMER_FUNC_TYPE)delayed_work_timer_fn,\ | 253 | delayed_work_timer_fn, \ |
| 254 | (_tflags) | TIMER_IRQSAFE); \ | 254 | (_tflags) | TIMER_IRQSAFE); \ |
| 255 | } while (0) | 255 | } while (0) |
| 256 | 256 | ||
| 257 | #define INIT_DELAYED_WORK(_work, _func) \ | 257 | #define INIT_DELAYED_WORK(_work, _func) \ |
