summaryrefslogtreecommitdiff
path: root/include/linux/timer.h
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-10-22 18:48:43 -0700
committerKees Cook <keescook@chromium.org>2017-11-21 15:57:15 -0800
commit919b250f8570618e84af544c3e18dad5210eb9b6 (patch)
tree1d40f3839c10ee62e70b5db4ac5ba30aa3e4a1c0 /include/linux/timer.h
parent188665b2d67db8953899551d1a9d4481b2a0ac60 (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>
Diffstat (limited to 'include/linux/timer.h')
-rw-r--r--include/linux/timer.h56
1 files changed, 20 insertions, 36 deletions
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 {
struct timer_list _name = \
__TIMER_INITIALIZER((TIMER_FUNC_TYPE)_function, 0)
+/*
+ * LOCKDEP and DEBUG timer interfaces.
+ */
void init_timer_key(struct timer_list *timer,
void (*func)(struct timer_list *), unsigned int flags,
const char *name, struct lock_class_key *key);
@@ -87,9 +90,7 @@ extern void init_timer_on_stack_key(struct timer_list *timer,
void (*func)(struct timer_list *),
unsigned int flags, const char *name,
struct lock_class_key *key);
-extern void destroy_timer_on_stack(struct timer_list *timer);
#else
-static inline void destroy_timer_on_stack(struct timer_list *timer) { }
static inline void init_timer_on_stack_key(struct timer_list *timer,
void (*func)(struct timer_list *),
unsigned int flags,
@@ -120,43 +121,26 @@ static inline void init_timer_on_stack_key(struct timer_list *timer,
init_timer_on_stack_key((_timer), (_fn), (_flags), NULL, NULL)
#endif
-#define __setup_timer(_timer, _fn, _flags) \
- do { \
- __init_timer((_timer), (_fn), (_flags)); \
- } while (0)
-
-#define __setup_timer_on_stack(_timer, _fn, _flags) \
- do { \
- __init_timer_on_stack((_timer), (_fn), (_flags)); \
- } while (0)
+/**
+ * timer_setup - prepare a timer for first use
+ * @timer: the timer in question
+ * @callback: the function to call when timer expires
+ * @flags: any TIMER_* flags
+ *
+ * Regular timer initialization should use either DEFINE_TIMER() above,
+ * or timer_setup(). For timers on the stack, timer_setup_on_stack() must
+ * be used and must be balanced with a call to destroy_timer_on_stack().
+ */
+#define timer_setup(timer, callback, flags) \
+ __init_timer((timer), (callback), (flags))
-#ifndef CONFIG_LOCKDEP
-static inline void timer_setup(struct timer_list *timer,
- void (*callback)(struct timer_list *),
- unsigned int flags)
-{
- __setup_timer(timer, (TIMER_FUNC_TYPE)callback, flags);
-}
+#define timer_setup_on_stack(timer, callback, flags) \
+ __init_timer_on_stack((timer), (callback), (flags))
-static inline void timer_setup_on_stack(struct timer_list *timer,
- void (*callback)(struct timer_list *),
- unsigned int flags)
-{
- __setup_timer_on_stack(timer, (TIMER_FUNC_TYPE)callback, flags);
-}
+#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
+extern void destroy_timer_on_stack(struct timer_list *timer);
#else
-/*
- * Under LOCKDEP, the timer lock_class_key (set up in __init_timer) needs
- * to be tied to the caller's context, so an inline (above) won't work. We
- * do want to keep the inline for argument type checking, though.
- */
-# define timer_setup(timer, callback, flags) \
- __setup_timer((timer), (TIMER_FUNC_TYPE)(callback), \
- (flags))
-# define timer_setup_on_stack(timer, callback, flags) \
- __setup_timer_on_stack((timer), \
- (TIMER_FUNC_TYPE)(callback), \
- (flags))
+static inline void destroy_timer_on_stack(struct timer_list *timer) { }
#endif
#define from_timer(var, callback_timer, timer_fieldname) \