aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2010-05-10 17:26:20 -0400
committerMatthew Garrett <mjg@redhat.com>2010-08-03 09:48:45 -0400
commit8cadd2831bf3abc94f4530e7fdbab7bb39b6b27d (patch)
tree4027798914cc3213692a4865797898a5ae0a0b49
parent81f61484f16decba0fb68400fe0036b337b4cdc7 (diff)
timer: add on-stack deferrable timer interfaces
In some cases (for instance with kernel threads) it may be desireable to use on-stack deferrable timers to get their power saving benefits. Add interfaces to support this for the IPS driver. Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Matthew Garrett <mjg@redhat.com>
-rw-r--r--include/linux/timer.h15
-rw-r--r--kernel/timer.c13
2 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/timer.h b/include/linux/timer.h
index ea965b857a50..38cf093ef62c 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -100,6 +100,13 @@ void init_timer_deferrable_key(struct timer_list *timer,
100 setup_timer_on_stack_key((timer), #timer, &__key, \ 100 setup_timer_on_stack_key((timer), #timer, &__key, \
101 (fn), (data)); \ 101 (fn), (data)); \
102 } while (0) 102 } while (0)
103#define setup_deferrable_timer_on_stack(timer, fn, data) \
104 do { \
105 static struct lock_class_key __key; \
106 setup_deferrable_timer_on_stack_key((timer), #timer, \
107 &__key, (fn), \
108 (data)); \
109 } while (0)
103#else 110#else
104#define init_timer(timer)\ 111#define init_timer(timer)\
105 init_timer_key((timer), NULL, NULL) 112 init_timer_key((timer), NULL, NULL)
@@ -111,6 +118,8 @@ void init_timer_deferrable_key(struct timer_list *timer,
111 setup_timer_key((timer), NULL, NULL, (fn), (data)) 118 setup_timer_key((timer), NULL, NULL, (fn), (data))
112#define setup_timer_on_stack(timer, fn, data)\ 119#define setup_timer_on_stack(timer, fn, data)\
113 setup_timer_on_stack_key((timer), NULL, NULL, (fn), (data)) 120 setup_timer_on_stack_key((timer), NULL, NULL, (fn), (data))
121#define setup_deferrable_timer_on_stack(timer, fn, data)\
122 setup_deferrable_timer_on_stack_key((timer), NULL, NULL, (fn), (data))
114#endif 123#endif
115 124
116#ifdef CONFIG_DEBUG_OBJECTS_TIMERS 125#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
@@ -150,6 +159,12 @@ static inline void setup_timer_on_stack_key(struct timer_list *timer,
150 init_timer_on_stack_key(timer, name, key); 159 init_timer_on_stack_key(timer, name, key);
151} 160}
152 161
162extern void setup_deferrable_timer_on_stack_key(struct timer_list *timer,
163 const char *name,
164 struct lock_class_key *key,
165 void (*function)(unsigned long),
166 unsigned long data);
167
153/** 168/**
154 * timer_pending - is a timer pending? 169 * timer_pending - is a timer pending?
155 * @timer: the timer in question 170 * @timer: the timer in question
diff --git a/kernel/timer.c b/kernel/timer.c
index ee305c8d4e18..efde11e197c4 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -577,6 +577,19 @@ static void __init_timer(struct timer_list *timer,
577 lockdep_init_map(&timer->lockdep_map, name, key, 0); 577 lockdep_init_map(&timer->lockdep_map, name, key, 0);
578} 578}
579 579
580void setup_deferrable_timer_on_stack_key(struct timer_list *timer,
581 const char *name,
582 struct lock_class_key *key,
583 void (*function)(unsigned long),
584 unsigned long data)
585{
586 timer->function = function;
587 timer->data = data;
588 init_timer_on_stack_key(timer, name, key);
589 timer_set_deferrable(timer);
590}
591EXPORT_SYMBOL_GPL(setup_deferrable_timer_on_stack_key);
592
580/** 593/**
581 * init_timer_key - initialize a timer 594 * init_timer_key - initialize a timer
582 * @timer: the timer to be initialized 595 * @timer: the timer to be initialized