2 * workqueue.h --- work queue handling for Linux.
5 #ifndef _LINUX_WORKQUEUE_H
6 #define _LINUX_WORKQUEUE_H
8 #include <linux/timer.h>
9 #include <linux/linkage.h>
10 #include <linux/bitops.h>
12 struct workqueue_struct;
14 typedef void (*work_func_t)(void *data);
17 unsigned long pending;
18 struct list_head entry;
25 struct work_struct work;
26 struct timer_list timer;
30 struct work_struct work;
33 #define __WORK_INITIALIZER(n, f, d) { \
34 .entry = { &(n).entry, &(n).entry }, \
39 #define __DELAYED_WORK_INITIALIZER(n, f, d) { \
40 .work = __WORK_INITIALIZER((n).work, (f), (d)), \
41 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
44 #define DECLARE_WORK(n, f, d) \
45 struct work_struct n = __WORK_INITIALIZER(n, f, d)
47 #define DECLARE_DELAYED_WORK(n, f, d) \
48 struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, d)
51 * initialize a work item's function and data pointers
53 #define PREPARE_WORK(_work, _func, _data) \
55 (_work)->func = (_func); \
56 (_work)->data = (_data); \
59 #define PREPARE_DELAYED_WORK(_work, _func, _data) \
60 PREPARE_WORK(&(_work)->work, (_func), (_data))
63 * initialize all of a work item in one go
65 #define INIT_WORK(_work, _func, _data) \
67 INIT_LIST_HEAD(&(_work)->entry); \
68 (_work)->pending = 0; \
69 PREPARE_WORK((_work), (_func), (_data)); \
72 #define INIT_DELAYED_WORK(_work, _func, _data) \
74 INIT_WORK(&(_work)->work, (_func), (_data)); \
75 init_timer(&(_work)->timer); \
79 extern struct workqueue_struct *__create_workqueue(const char *name,
81 #define create_workqueue(name) __create_workqueue((name), 0)
82 #define create_singlethread_workqueue(name) __create_workqueue((name), 1)
84 extern void destroy_workqueue(struct workqueue_struct *wq);
86 extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
87 extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay));
88 extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
89 struct delayed_work *work, unsigned long delay);
90 extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
92 extern int FASTCALL(schedule_work(struct work_struct *work));
93 extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay));
95 extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay);
96 extern int schedule_on_each_cpu(work_func_t func, void *info);
97 extern void flush_scheduled_work(void);
98 extern int current_is_keventd(void);
99 extern int keventd_up(void);
101 extern void init_workqueues(void);
102 void cancel_rearming_delayed_work(struct delayed_work *work);
103 void cancel_rearming_delayed_workqueue(struct workqueue_struct *,
104 struct delayed_work *);
105 int execute_in_process_context(work_func_t fn, void *, struct execute_work *);
108 * Kill off a pending schedule_delayed_work(). Note that the work callback
109 * function may still be running on return from cancel_delayed_work(). Run
110 * flush_scheduled_work() to wait on it.
112 static inline int cancel_delayed_work(struct delayed_work *work)
116 ret = del_timer_sync(&work->timer);
118 clear_bit(0, &work->work.pending);