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>
This commit is contained in:
@@ -164,9 +164,9 @@ extern void __kthread_init_worker(struct kthread_worker *worker,
|
|||||||
#define kthread_init_delayed_work(dwork, fn) \
|
#define kthread_init_delayed_work(dwork, fn) \
|
||||||
do { \
|
do { \
|
||||||
kthread_init_work(&(dwork)->work, (fn)); \
|
kthread_init_work(&(dwork)->work, (fn)); \
|
||||||
__setup_timer(&(dwork)->timer, \
|
__init_timer(&(dwork)->timer, \
|
||||||
(TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\
|
kthread_delayed_work_timer_fn, \
|
||||||
TIMER_IRQSAFE); \
|
TIMER_IRQSAFE); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int kthread_worker_fn(void *worker_ptr);
|
int kthread_worker_fn(void *worker_ptr);
|
||||||
|
@@ -78,6 +78,9 @@ struct timer_list {
|
|||||||
struct timer_list _name = \
|
struct timer_list _name = \
|
||||||
__TIMER_INITIALIZER((TIMER_FUNC_TYPE)_function, 0)
|
__TIMER_INITIALIZER((TIMER_FUNC_TYPE)_function, 0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LOCKDEP and DEBUG timer interfaces.
|
||||||
|
*/
|
||||||
void init_timer_key(struct timer_list *timer,
|
void init_timer_key(struct timer_list *timer,
|
||||||
void (*func)(struct timer_list *), unsigned int flags,
|
void (*func)(struct timer_list *), unsigned int flags,
|
||||||
const char *name, struct lock_class_key *key);
|
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 *),
|
void (*func)(struct timer_list *),
|
||||||
unsigned int flags, const char *name,
|
unsigned int flags, const char *name,
|
||||||
struct lock_class_key *key);
|
struct lock_class_key *key);
|
||||||
extern void destroy_timer_on_stack(struct timer_list *timer);
|
|
||||||
#else
|
#else
|
||||||
static inline void destroy_timer_on_stack(struct timer_list *timer) { }
|
|
||||||
static inline void init_timer_on_stack_key(struct timer_list *timer,
|
static inline void init_timer_on_stack_key(struct timer_list *timer,
|
||||||
void (*func)(struct timer_list *),
|
void (*func)(struct timer_list *),
|
||||||
unsigned int flags,
|
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)
|
init_timer_on_stack_key((_timer), (_fn), (_flags), NULL, NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __setup_timer(_timer, _fn, _flags) \
|
/**
|
||||||
do { \
|
* timer_setup - prepare a timer for first use
|
||||||
__init_timer((_timer), (_fn), (_flags)); \
|
* @timer: the timer in question
|
||||||
} while (0)
|
* @callback: the function to call when timer expires
|
||||||
|
* @flags: any TIMER_* flags
|
||||||
#define __setup_timer_on_stack(_timer, _fn, _flags) \
|
*
|
||||||
do { \
|
* Regular timer initialization should use either DEFINE_TIMER() above,
|
||||||
__init_timer_on_stack((_timer), (_fn), (_flags)); \
|
* or timer_setup(). For timers on the stack, timer_setup_on_stack() must
|
||||||
} while (0)
|
* be used and must be balanced with a call to destroy_timer_on_stack().
|
||||||
|
|
||||||
#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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
#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) \
|
#define timer_setup(timer, callback, flags) \
|
||||||
__setup_timer((timer), (TIMER_FUNC_TYPE)(callback), \
|
__init_timer((timer), (callback), (flags))
|
||||||
(flags))
|
|
||||||
# define timer_setup_on_stack(timer, callback, flags) \
|
#define timer_setup_on_stack(timer, callback, flags) \
|
||||||
__setup_timer_on_stack((timer), \
|
__init_timer_on_stack((timer), (callback), (flags))
|
||||||
(TIMER_FUNC_TYPE)(callback), \
|
|
||||||
(flags))
|
#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
|
||||||
|
extern void destroy_timer_on_stack(struct timer_list *timer);
|
||||||
|
#else
|
||||||
|
static inline void destroy_timer_on_stack(struct timer_list *timer) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define from_timer(var, callback_timer, timer_fieldname) \
|
#define from_timer(var, callback_timer, timer_fieldname) \
|
||||||
|
@@ -241,17 +241,17 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
|
|||||||
#define __INIT_DELAYED_WORK(_work, _func, _tflags) \
|
#define __INIT_DELAYED_WORK(_work, _func, _tflags) \
|
||||||
do { \
|
do { \
|
||||||
INIT_WORK(&(_work)->work, (_func)); \
|
INIT_WORK(&(_work)->work, (_func)); \
|
||||||
__setup_timer(&(_work)->timer, \
|
__init_timer(&(_work)->timer, \
|
||||||
(TIMER_FUNC_TYPE)delayed_work_timer_fn, \
|
delayed_work_timer_fn, \
|
||||||
(_tflags) | TIMER_IRQSAFE); \
|
(_tflags) | TIMER_IRQSAFE); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define __INIT_DELAYED_WORK_ONSTACK(_work, _func, _tflags) \
|
#define __INIT_DELAYED_WORK_ONSTACK(_work, _func, _tflags) \
|
||||||
do { \
|
do { \
|
||||||
INIT_WORK_ONSTACK(&(_work)->work, (_func)); \
|
INIT_WORK_ONSTACK(&(_work)->work, (_func)); \
|
||||||
__setup_timer_on_stack(&(_work)->timer, \
|
__init_timer_on_stack(&(_work)->timer, \
|
||||||
(TIMER_FUNC_TYPE)delayed_work_timer_fn,\
|
delayed_work_timer_fn, \
|
||||||
(_tflags) | TIMER_IRQSAFE); \
|
(_tflags) | TIMER_IRQSAFE); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define INIT_DELAYED_WORK(_work, _func) \
|
#define INIT_DELAYED_WORK(_work, _func) \
|
||||||
|
Reference in New Issue
Block a user