timer: Clean up timer initializers
Over time, timer initializers became messy with unnecessarily duplicated code which are inconsistently spread across timer.h and timer.c. This patch cleans up timer initializers. * timer.c::__init_timer() is renamed to do_init_timer(). * __TIMER_INITIALIZER() added. It takes @flags and all initializers are wrappers around it. * init_timer[_on_stack]_key() now take @flags. * __init_timer[_on_stack]() added. They take @flags and all init macros are wrappers around them. * __setup_timer[_on_stack]() added. It uses __init_timer() and takes @flags. All setup macros are wrappers around the two. Note that this patch doesn't add missing init/setup combinations - e.g. init_timer_deferrable_on_stack(). Adding missing ones is trivial. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: torvalds@linux-foundation.org Cc: peterz@infradead.org Link: http://lkml.kernel.org/r/1344449428-24962-4-git-send-email-tj@kernel.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
committed by
Thomas Gleixner
parent
5a9af38d05
commit
fc683995a6
@@ -100,11 +100,6 @@ static inline struct tvec_base *tbase_get_base(struct tvec_base *base)
|
||||
return ((struct tvec_base *)((unsigned long)base & ~TIMER_FLAG_MASK));
|
||||
}
|
||||
|
||||
static inline void timer_set_deferrable(struct timer_list *timer)
|
||||
{
|
||||
timer->base = TBASE_MAKE_DEFERRED(timer->base);
|
||||
}
|
||||
|
||||
static inline void
|
||||
timer_set_base(struct timer_list *timer, struct tvec_base *new_base)
|
||||
{
|
||||
@@ -564,16 +559,14 @@ static inline void debug_timer_assert_init(struct timer_list *timer)
|
||||
debug_object_assert_init(timer, &timer_debug_descr);
|
||||
}
|
||||
|
||||
static void __init_timer(struct timer_list *timer,
|
||||
const char *name,
|
||||
struct lock_class_key *key);
|
||||
static void do_init_timer(struct timer_list *timer, unsigned int flags,
|
||||
const char *name, struct lock_class_key *key);
|
||||
|
||||
void init_timer_on_stack_key(struct timer_list *timer,
|
||||
const char *name,
|
||||
struct lock_class_key *key)
|
||||
void init_timer_on_stack_key(struct timer_list *timer, unsigned int flags,
|
||||
const char *name, struct lock_class_key *key)
|
||||
{
|
||||
debug_object_init_on_stack(timer, &timer_debug_descr);
|
||||
__init_timer(timer, name, key);
|
||||
do_init_timer(timer, flags, name, key);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(init_timer_on_stack_key);
|
||||
|
||||
@@ -614,12 +607,13 @@ static inline void debug_assert_init(struct timer_list *timer)
|
||||
debug_timer_assert_init(timer);
|
||||
}
|
||||
|
||||
static void __init_timer(struct timer_list *timer,
|
||||
const char *name,
|
||||
struct lock_class_key *key)
|
||||
static void do_init_timer(struct timer_list *timer, unsigned int flags,
|
||||
const char *name, struct lock_class_key *key)
|
||||
{
|
||||
struct tvec_base *base = __raw_get_cpu_var(tvec_bases);
|
||||
|
||||
timer->entry.next = NULL;
|
||||
timer->base = __raw_get_cpu_var(tvec_bases);
|
||||
timer->base = (void *)((unsigned long)base | flags);
|
||||
timer->slack = -1;
|
||||
#ifdef CONFIG_TIMER_STATS
|
||||
timer->start_site = NULL;
|
||||
@@ -629,22 +623,10 @@ static void __init_timer(struct timer_list *timer,
|
||||
lockdep_init_map(&timer->lockdep_map, name, key, 0);
|
||||
}
|
||||
|
||||
void setup_deferrable_timer_on_stack_key(struct timer_list *timer,
|
||||
const char *name,
|
||||
struct lock_class_key *key,
|
||||
void (*function)(unsigned long),
|
||||
unsigned long data)
|
||||
{
|
||||
timer->function = function;
|
||||
timer->data = data;
|
||||
init_timer_on_stack_key(timer, name, key);
|
||||
timer_set_deferrable(timer);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(setup_deferrable_timer_on_stack_key);
|
||||
|
||||
/**
|
||||
* init_timer_key - initialize a timer
|
||||
* @timer: the timer to be initialized
|
||||
* @flags: timer flags
|
||||
* @name: name of the timer
|
||||
* @key: lockdep class key of the fake lock used for tracking timer
|
||||
* sync lock dependencies
|
||||
@@ -652,24 +634,14 @@ EXPORT_SYMBOL_GPL(setup_deferrable_timer_on_stack_key);
|
||||
* init_timer_key() must be done to a timer prior calling *any* of the
|
||||
* other timer functions.
|
||||
*/
|
||||
void init_timer_key(struct timer_list *timer,
|
||||
const char *name,
|
||||
struct lock_class_key *key)
|
||||
void init_timer_key(struct timer_list *timer, unsigned int flags,
|
||||
const char *name, struct lock_class_key *key)
|
||||
{
|
||||
debug_init(timer);
|
||||
__init_timer(timer, name, key);
|
||||
do_init_timer(timer, flags, name, key);
|
||||
}
|
||||
EXPORT_SYMBOL(init_timer_key);
|
||||
|
||||
void init_timer_deferrable_key(struct timer_list *timer,
|
||||
const char *name,
|
||||
struct lock_class_key *key)
|
||||
{
|
||||
init_timer_key(timer, name, key);
|
||||
timer_set_deferrable(timer);
|
||||
}
|
||||
EXPORT_SYMBOL(init_timer_deferrable_key);
|
||||
|
||||
static inline void detach_timer(struct timer_list *timer, bool clear_pending)
|
||||
{
|
||||
struct list_head *entry = &timer->entry;
|
||||
|
Reference in New Issue
Block a user