diff options
author | Phil Carmody <ext-phil.2.carmody@nokia.com> | 2010-10-20 15:57:33 -0700 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-10-21 17:30:06 +0200 |
commit | dd6414b50fa2b1cd247a8aa8f8bd42414b7453e1 (patch) | |
tree | d6572c35cf1997e2d18e451cb44742c89723d804 /include/linux/workqueue.h | |
parent | 2bf1c05e3c406925e498d06da66b4828f0209ea6 (diff) | |
download | talos-obmc-linux-dd6414b50fa2b1cd247a8aa8f8bd42414b7453e1.tar.gz talos-obmc-linux-dd6414b50fa2b1cd247a8aa8f8bd42414b7453e1.zip |
timer: Permit statically-declared work with deferrable timers
Currently, you have to just define a delayed_work uninitialised, and then
initialise it before first use. That's a tad clumsy. At risk of playing
mind-games with the compiler, fooling it into doing pointer arithmetic
with compile-time-constants, this lets clients properly initialise delayed
work with deferrable timers statically.
This patch was inspired by the issues which lead Artem Bityutskiy to
commit 8eab945c5616fc984 ("sunrpc: make the cache cleaner workqueue
deferrable").
Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Cc: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/workqueue.h')
-rw-r--r-- | include/linux/workqueue.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index f11100f96482..88238c15ec3e 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -127,12 +127,20 @@ struct execute_work { .timer = TIMER_INITIALIZER(NULL, 0, 0), \ } +#define __DEFERRED_WORK_INITIALIZER(n, f) { \ + .work = __WORK_INITIALIZER((n).work, (f)), \ + .timer = TIMER_DEFERRED_INITIALIZER(NULL, 0, 0), \ + } + #define DECLARE_WORK(n, f) \ struct work_struct n = __WORK_INITIALIZER(n, f) #define DECLARE_DELAYED_WORK(n, f) \ struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f) +#define DECLARE_DEFERRED_WORK(n, f) \ + struct delayed_work n = __DEFERRED_WORK_INITIALIZER(n, f) + /* * initialize a work item's function pointer */ |