Commit-ID:  8c20feb60604d91a29cd7fef8ac758bd92d9fd2c
Gitweb:     https://git.kernel.org/tip/8c20feb60604d91a29cd7fef8ac758bd92d9fd2c
Author:     Kees Cook <keesc...@chromium.org>
AuthorDate: Wed, 4 Oct 2017 16:27:07 -0700
Committer:  Thomas Gleixner <t...@linutronix.de>
CommitDate: Thu, 5 Oct 2017 15:01:22 +0200

workqueue: Convert callback to use from_timer()

In preparation for unconditionally passing the struct timer_list pointer
to all timer callbacks, switch workqueue to use from_timer() and pass the
timer pointer explicitly.

Signed-off-by: Kees Cook <keesc...@chromium.org>
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
Cc: linux-m...@linux-mips.org
Cc: Petr Mladek <pmla...@suse.com>
Cc: Benjamin Herrenschmidt <b...@kernel.crashing.org>
Cc: Lai Jiangshan <jiangshan...@gmail.com>
Cc: Sebastian Reichel <s...@kernel.org>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Pavel Machek <pa...@ucw.cz>
Cc: linux1394-de...@lists.sourceforge.net
Cc: Chris Metcalf <cmetc...@mellanox.com>
Cc: linux-s...@vger.kernel.org
Cc: linux-wirel...@vger.kernel.org
Cc: "James E.J. Bottomley" <j...@linux.vnet.ibm.com>
Cc: Wim Van Sebroeck <w...@iguana.be>
Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: Ursula Braun <ubr...@linux.vnet.ibm.com>
Cc: Geert Uytterhoeven <ge...@linux-m68k.org>
Cc: Viresh Kumar <viresh.ku...@linaro.org>
Cc: Harish Patil <harish.pa...@cavium.com>
Cc: Stephen Boyd <sb...@codeaurora.org>
Cc: Guenter Roeck <li...@roeck-us.net>
Cc: Manish Chopra <manish.cho...@cavium.com>
Cc: Len Brown <len.br...@intel.com>
Cc: Arnd Bergmann <a...@arndb.de>
Cc: linux...@vger.kernel.org
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
Cc: Martin Schwidefsky <schwidef...@de.ibm.com>
Cc: Julian Wiedmann <j...@linux.vnet.ibm.com>
Cc: John Stultz <john.stu...@linaro.org>
Cc: Mark Gross <mark.gr...@intel.com>
Cc: linux-watch...@vger.kernel.org
Cc: linux-s...@vger.kernel.org
Cc: "Martin K. Petersen" <martin.peter...@oracle.com>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <r...@rjwysocki.net>
Cc: Oleg Nesterov <o...@redhat.com>
Cc: Ralf Baechle <r...@linux-mips.org>
Cc: Stefan Richter <stef...@s5r6.in-berlin.de>
Cc: Michael Reed <m...@sgi.com>
Cc: net...@vger.kernel.org
Cc: Tejun Heo <t...@kernel.org>
Cc: Andrew Morton <a...@linux-foundation.org>
Cc: linuxppc-...@lists.ozlabs.org
Cc: Sudip Mukherjee <sudipm.mukher...@gmail.com>
Link: 
https://lkml.kernel.org/r/1507159627-127660-14-git-send-email-keesc...@chromium.org

---
 include/linux/workqueue.h | 15 ++++++++-------
 kernel/workqueue.c        |  7 +++----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index f496026..f3c47a0 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -17,7 +17,7 @@ struct workqueue_struct;
 
 struct work_struct;
 typedef void (*work_func_t)(struct work_struct *work);
-void delayed_work_timer_fn(unsigned long __data);
+void delayed_work_timer_fn(struct timer_list *t);
 
 /*
  * The first word is the work queue pointer and the flags rolled into
@@ -175,8 +175,8 @@ struct execute_work {
 
 #define __DELAYED_WORK_INITIALIZER(n, f, tflags) {                     \
        .work = __WORK_INITIALIZER((n).work, (f)),                      \
-       .timer = __TIMER_INITIALIZER(delayed_work_timer_fn,             \
-                                    (unsigned long)&(n),               \
+       .timer = __TIMER_INITIALIZER((TIMER_FUNC_TYPE)delayed_work_timer_fn,\
+                                    (TIMER_DATA_TYPE)&(n.timer),       \
                                     (tflags) | TIMER_IRQSAFE),         \
        }
 
@@ -241,8 +241,9 @@ static inline unsigned int work_static(struct work_struct 
*work) { return 0; }
 #define __INIT_DELAYED_WORK(_work, _func, _tflags)                     \
        do {                                                            \
                INIT_WORK(&(_work)->work, (_func));                     \
-               __setup_timer(&(_work)->timer, delayed_work_timer_fn,   \
-                             (unsigned long)(_work),                   \
+               __setup_timer(&(_work)->timer,                          \
+                             (TIMER_FUNC_TYPE)delayed_work_timer_fn,   \
+                             (TIMER_DATA_TYPE)&(_work)->timer,         \
                              (_tflags) | TIMER_IRQSAFE);               \
        } while (0)
 
@@ -250,8 +251,8 @@ static inline unsigned int work_static(struct work_struct 
*work) { return 0; }
        do {                                                            \
                INIT_WORK_ONSTACK(&(_work)->work, (_func));             \
                __setup_timer_on_stack(&(_work)->timer,                 \
-                                      delayed_work_timer_fn,           \
-                                      (unsigned long)(_work),          \
+                                      (TIMER_FUNC_TYPE)delayed_work_timer_fn,\
+                                      (TIMER_DATA_TYPE)&(_work)->timer,\
                                       (_tflags) | TIMER_IRQSAFE);      \
        } while (0)
 
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a5361fc..c77fdf6 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1492,9 +1492,9 @@ bool queue_work_on(int cpu, struct workqueue_struct *wq,
 }
 EXPORT_SYMBOL(queue_work_on);
 
-void delayed_work_timer_fn(unsigned long __data)
+void delayed_work_timer_fn(struct timer_list *t)
 {
-       struct delayed_work *dwork = (struct delayed_work *)__data;
+       struct delayed_work *dwork = from_timer(dwork, t, timer);
 
        /* should have been called from irqsafe timer with irq already off */
        __queue_work(dwork->cpu, dwork->wq, &dwork->work);
@@ -1508,8 +1508,7 @@ static void __queue_delayed_work(int cpu, struct 
workqueue_struct *wq,
        struct work_struct *work = &dwork->work;
 
        WARN_ON_ONCE(!wq);
-       WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
-                    timer->data != (unsigned long)dwork);
+       WARN_ON_ONCE(timer->function != (TIMER_FUNC_TYPE)delayed_work_timer_fn);
        WARN_ON_ONCE(timer_pending(timer));
        WARN_ON_ONCE(!list_empty(&work->entry));
 

Reply via email to