workqueue: mark a work item being canceled as such
[deliverable/linux.git] / include / linux / workqueue.h
index af155450cabb8a91ec33d2991a011d43437e23f6..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)
 
 /**
@@ -365,23 +383,24 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
 
 extern void destroy_workqueue(struct workqueue_struct *wq);
 
-extern int queue_work(struct workqueue_struct *wq, struct work_struct *work);
-extern int queue_work_on(int cpu, struct workqueue_struct *wq,
+extern bool queue_work_on(int cpu, struct workqueue_struct *wq,
                        struct work_struct *work);
-extern int queue_delayed_work(struct workqueue_struct *wq,
+extern bool queue_work(struct workqueue_struct *wq, struct work_struct *work);
+extern bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
                        struct delayed_work *work, unsigned long delay);
-extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
+extern bool queue_delayed_work(struct workqueue_struct *wq,
                        struct delayed_work *work, unsigned long delay);
 
 extern void flush_workqueue(struct workqueue_struct *wq);
 extern void drain_workqueue(struct workqueue_struct *wq);
 extern void flush_scheduled_work(void);
 
-extern int schedule_work(struct work_struct *work);
-extern int schedule_work_on(int cpu, struct work_struct *work);
-extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay);
-extern int schedule_delayed_work_on(int cpu, struct delayed_work *work,
-                                       unsigned long delay);
+extern bool schedule_work_on(int cpu, struct work_struct *work);
+extern bool schedule_work(struct work_struct *work);
+extern bool schedule_delayed_work_on(int cpu, struct delayed_work *work,
+                                    unsigned long delay);
+extern bool schedule_delayed_work(struct delayed_work *work,
+                                 unsigned long delay);
 extern int schedule_on_each_cpu(work_func_t func);
 extern int keventd_up(void);
 
This page took 0.048348 seconds and 5 git commands to generate.