workqueue: mark a work item being canceled as such
[deliverable/linux.git] / include / linux / workqueue.h
index 278dc5ddb73f1adcb6e41cf612ba6efb3e0d3c89..5f4aeaa9f3e6d9b800893842a744fc9cc8fa0c4b 100644 (file)
@@ -16,6 +16,7 @@ struct workqueue_struct;
 
 struct work_struct;
 typedef void (*work_func_t)(struct work_struct *work);
+void delayed_work_timer_fn(unsigned long __data);
 
 /*
  * The first word is the work queue pointer and the flags rolled into
@@ -67,9 +68,18 @@ enum {
        WORK_STRUCT_FLAG_BITS   = WORK_STRUCT_COLOR_SHIFT +
                                  WORK_STRUCT_COLOR_BITS,
 
+       /* data contains off-queue information when !WORK_STRUCT_CWQ */
+       WORK_OFFQ_FLAG_BASE     = WORK_STRUCT_FLAG_BITS,
+
+       WORK_OFFQ_CANCELING     = (1 << WORK_OFFQ_FLAG_BASE),
+
+       WORK_OFFQ_FLAG_BITS     = 1,
+       WORK_OFFQ_CPU_SHIFT     = WORK_OFFQ_FLAG_BASE + WORK_OFFQ_FLAG_BITS,
+
+       /* convenience constants */
        WORK_STRUCT_FLAG_MASK   = (1UL << WORK_STRUCT_FLAG_BITS) - 1,
        WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK,
-       WORK_STRUCT_NO_CPU      = WORK_CPU_NONE << WORK_STRUCT_FLAG_BITS,
+       WORK_STRUCT_NO_CPU      = (unsigned long)WORK_CPU_NONE << WORK_OFFQ_CPU_SHIFT,
 
        /* bit mask for work_busy() return values */
        WORK_BUSY_PENDING       = 1 << 0,
@@ -124,12 +134,14 @@ struct execute_work {
 
 #define __DELAYED_WORK_INITIALIZER(n, f) {                     \
        .work = __WORK_INITIALIZER((n).work, (f)),              \
-       .timer = TIMER_INITIALIZER(NULL, 0, 0),                 \
+       .timer = TIMER_INITIALIZER(delayed_work_timer_fn,       \
+                               0, (unsigned long)&(n)),        \
        }
 
 #define __DEFERRED_WORK_INITIALIZER(n, f) {                    \
        .work = __WORK_INITIALIZER((n).work, (f)),              \
-       .timer = TIMER_DEFERRED_INITIALIZER(NULL, 0, 0),        \
+       .timer = TIMER_DEFERRED_INITIALIZER(delayed_work_timer_fn, \
+                               0, (unsigned long)&(n)),        \
        }
 
 #define DECLARE_WORK(n, f)                                     \
@@ -207,18 +219,24 @@ static inline unsigned int work_static(struct work_struct *work) { return 0; }
        do {                                                    \
                INIT_WORK(&(_work)->work, (_func));             \
                init_timer(&(_work)->timer);                    \
+               (_work)->timer.function = delayed_work_timer_fn;\
+               (_work)->timer.data = (unsigned long)(_work);   \
        } while (0)
 
 #define INIT_DELAYED_WORK_ONSTACK(_work, _func)                        \
        do {                                                    \
                INIT_WORK_ONSTACK(&(_work)->work, (_func));     \
                init_timer_on_stack(&(_work)->timer);           \
+               (_work)->timer.function = delayed_work_timer_fn;\
+               (_work)->timer.data = (unsigned long)(_work);   \
        } while (0)
 
 #define INIT_DELAYED_WORK_DEFERRABLE(_work, _func)             \
        do {                                                    \
                INIT_WORK(&(_work)->work, (_func));             \
                init_timer_deferrable(&(_work)->timer);         \
+               (_work)->timer.function = delayed_work_timer_fn;\
+               (_work)->timer.data = (unsigned long)(_work);   \
        } while (0)
 
 /**
This page took 0.026528 seconds and 5 git commands to generate.