1 #ifndef __LINUX_WORKQUEUE_WRAPPER_H
2 #define __LINUX_WORKQUEUE_WRAPPER_H 1
4 #include_next <linux/workqueue.h>
6 #include <linux/version.h>
7 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
9 /* Older kernels have an implementation of work queues with some very bad
10 * characteristics when trying to cancel work (potential deadlocks, use after
11 * free, etc. Here we directly use timers instead for delayed work. It's not
12 * optimal but it is better than the alternative. Note that work queues
13 * normally run in process context but this will cause them to operate in
17 #include <linux/timer.h>
19 #undef DECLARE_DELAYED_WORK
20 #define DECLARE_DELAYED_WORK(n, f) \
21 struct timer_list n = TIMER_INITIALIZER((void (*)(unsigned long))f, 0, 0)
23 #define schedule_delayed_work rpl_schedule_delayed_work
24 static inline int schedule_delayed_work(struct timer_list *timer, unsigned long delay)
26 if (timer_pending(timer))
29 mod_timer(timer, jiffies + delay);
33 #define cancel_delayed_work_sync rpl_cancel_delayed_work_sync
34 static inline int cancel_delayed_work_sync(struct timer_list *timer)
36 return del_timer_sync(timer);
39 #endif /* kernel version < 2.6.23 */