1
2
3
4
5#ifndef _LINUX_WORKQUEUE_H
6#define _LINUX_WORKQUEUE_H
7
8#include <linux/timer.h>
9#include <linux/linkage.h>
10
11struct workqueue_struct;
12
13struct work_struct {
14 unsigned long pending;
15 struct list_head entry;
16 void (*func)(void *);
17 void *data;
18 void *wq_data;
19 struct timer_list timer;
20};
21
22#define __WORK_INITIALIZER(n, f, d) { \
23 .entry = { &(n).entry, &(n).entry }, \
24 .func = (f), \
25 .data = (d), \
26 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
27 }
28
29#define DECLARE_WORK(n, f, d) \
30 struct work_struct n = __WORK_INITIALIZER(n, f, d)
31
32
33
34
35#define PREPARE_WORK(_work, _func, _data) \
36 do { \
37 (_work)->func = _func; \
38 (_work)->data = _data; \
39 } while (0)
40
41
42
43
44#define INIT_WORK(_work, _func, _data) \
45 do { \
46 INIT_LIST_HEAD(&(_work)->entry); \
47 (_work)->pending = 0; \
48 PREPARE_WORK((_work), (_func), (_data)); \
49 init_timer(&(_work)->timer); \
50 } while (0)
51
52extern struct workqueue_struct *create_workqueue(const char *name);
53extern void destroy_workqueue(struct workqueue_struct *wq);
54
55extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
56extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay));
57extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
58
59extern int FASTCALL(schedule_work(struct work_struct *work));
60extern int FASTCALL(schedule_delayed_work(struct work_struct *work, unsigned long delay));
61extern void flush_scheduled_work(void);
62extern int current_is_keventd(void);
63extern int keventd_up(void);
64
65extern void init_workqueues(void);
66
67
68
69
70
71
72static inline int cancel_delayed_work(struct work_struct *work)
73{
74 return del_timer_sync(&work->timer);
75}
76
77#endif
78
79