aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/workqueue.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/workqueue.h')
-rw-r--r--include/linux/workqueue.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index cef40b22ff9a..ecc017d24cf3 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -14,11 +14,15 @@ struct workqueue_struct;
14typedef void (*work_func_t)(void *data); 14typedef void (*work_func_t)(void *data);
15 15
16struct work_struct { 16struct work_struct {
17 unsigned long pending; 17 /* the first word is the work queue pointer and the pending flag
18 * rolled into one */
19 unsigned long management;
20#define WORK_STRUCT_PENDING 0 /* T if work item pending execution */
21#define WORK_STRUCT_FLAG_MASK (3UL)
22#define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK)
18 struct list_head entry; 23 struct list_head entry;
19 work_func_t func; 24 work_func_t func;
20 void *data; 25 void *data;
21 void *wq_data;
22}; 26};
23 27
24struct delayed_work { 28struct delayed_work {
@@ -65,7 +69,7 @@ struct execute_work {
65#define INIT_WORK(_work, _func, _data) \ 69#define INIT_WORK(_work, _func, _data) \
66 do { \ 70 do { \
67 INIT_LIST_HEAD(&(_work)->entry); \ 71 INIT_LIST_HEAD(&(_work)->entry); \
68 (_work)->pending = 0; \ 72 (_work)->management = 0; \
69 PREPARE_WORK((_work), (_func), (_data)); \ 73 PREPARE_WORK((_work), (_func), (_data)); \
70 } while (0) 74 } while (0)
71 75
@@ -75,6 +79,21 @@ struct execute_work {
75 init_timer(&(_work)->timer); \ 79 init_timer(&(_work)->timer); \
76 } while (0) 80 } while (0)
77 81
82/**
83 * work_pending - Find out whether a work item is currently pending
84 * @work: The work item in question
85 */
86#define work_pending(work) \
87 test_bit(WORK_STRUCT_PENDING, &(work)->management)
88
89/**
90 * delayed_work_pending - Find out whether a delayable work item is currently
91 * pending
92 * @work: The work item in question
93 */
94#define delayed_work_pending(work) \
95 test_bit(WORK_STRUCT_PENDING, &(work)->work.management)
96
78 97
79extern struct workqueue_struct *__create_workqueue(const char *name, 98extern struct workqueue_struct *__create_workqueue(const char *name,
80 int singlethread); 99 int singlethread);
@@ -115,7 +134,7 @@ static inline int cancel_delayed_work(struct delayed_work *work)
115 134
116 ret = del_timer_sync(&work->timer); 135 ret = del_timer_sync(&work->timer);
117 if (ret) 136 if (ret)
118 clear_bit(0, &work->work.pending); 137 clear_bit(WORK_STRUCT_PENDING, &work->work.management);
119 return ret; 138 return ret;
120} 139}
121 140