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;
15 unsigned long pending;
16 struct list_head entry;
23 struct work_struct work;
24 struct timer_list timer;
28 struct work_struct work;
31 #define __WORK_INITIALIZER(n, f, d) { \
32 .entry = { &(n).entry, &(n).entry }, \
37 #define __DELAYED_WORK_INITIALIZER(n, f, d) { \
38 .work = __WORK_INITIALIZER((n).work, (f), (d)), \
39 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
42 #define DECLARE_WORK(n, f, d) \
43 struct work_struct n = __WORK_INITIALIZER(n, f, d)
45 #define DECLARE_DELAYED_WORK(n, f, d) \
46 struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, d)
49 * initialize a work item's function and data pointers
51 #define PREPARE_WORK(_work, _func, _data) \
53 (_work)->func = (_func); \
54 (_work)->data = (_data); \
57 #define PREPARE_DELAYED_WORK(_work, _func, _data) \
58 PREPARE_WORK(&(_work)->work, (_func), (_data))
61 * initialize all of a work item in one go
63 #define INIT_WORK(_work, _func, _data) \
65 INIT_LIST_HEAD(&(_work)->entry); \
66 (_work)->pending = 0; \
67 PREPARE_WORK((_work), (_func), (_data)); \
70 #define INIT_DELAYED_WORK(_work, _func, _data) \
72 INIT_WORK(&(_work)->work, (_func), (_data)); \
73 init_timer(&(_work)->timer); \
77 extern struct workqueue_struct *__create_workqueue(const char *name,
79 #define create_workqueue(name) __create_workqueue((name), 0)
80 #define create_singlethread_workqueue(name) __create_workqueue((name), 1)
82 extern void destroy_workqueue(struct workqueue_struct *wq);
84 extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
85 extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay));
86 extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
87 struct delayed_work *work, unsigned long delay);
88 extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
90 extern int FASTCALL(schedule_work(struct work_struct *work));
91 extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay));
93 extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay);
94 extern int schedule_on_each_cpu(void (*func)(void *info), void *info);
95 extern void flush_scheduled_work(void);
96 extern int current_is_keventd(void);
97 extern int keventd_up(void);
99 extern void init_workqueues(void);
100 void cancel_rearming_delayed_work(struct delayed_work *work);
101 void cancel_rearming_delayed_workqueue(struct workqueue_struct *,
102 struct delayed_work *);
103 int execute_in_process_context(void (*fn)(void *), void *,
104 struct execute_work *);
107 * Kill off a pending schedule_delayed_work(). Note that the work callback
108 * function may still be running on return from cancel_delayed_work(). Run
109 * flush_scheduled_work() to wait on it.
111 static inline int cancel_delayed_work(struct delayed_work *work)
115 ret = del_timer_sync(&work->timer);
117 clear_bit(0, &work->work.pending);