Skip to content

Commit fe5c3b6

Browse files
keesKAGA-KOKO
authored andcommitted
kthread: Convert callback to use from_timer()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch kthread to use from_timer() and pass the timer pointer explicitly. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-mips@linux-mips.org Cc: Len Brown <len.brown@intel.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Lai Jiangshan <jiangshanlai@gmail.com> Cc: Sebastian Reichel <sre@kernel.org> Cc: Kalle Valo <kvalo@qca.qualcomm.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Pavel Machek <pavel@ucw.cz> Cc: linux1394-devel@lists.sourceforge.net Cc: Chris Metcalf <cmetcalf@mellanox.com> Cc: linux-s390@vger.kernel.org Cc: linux-wireless@vger.kernel.org Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com> Cc: Wim Van Sebroeck <wim@iguana.be> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Ursula Braun <ubraun@linux.vnet.ibm.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Viresh Kumar <viresh.kumar@linaro.org> Cc: Harish Patil <harish.patil@cavium.com> Cc: Stephen Boyd <sboyd@codeaurora.org> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Manish Chopra <manish.chopra@cavium.com> Cc: Petr Mladek <pmladek@suse.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: linux-pm@vger.kernel.org Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Julian Wiedmann <jwi@linux.vnet.ibm.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Mark Gross <mark.gross@intel.com> Cc: linux-watchdog@vger.kernel.org Cc: linux-scsi@vger.kernel.org Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de> Cc: Michael Reed <mdr@sgi.com> Cc: netdev@vger.kernel.org Cc: Tejun Heo <tj@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: linuxppc-dev@lists.ozlabs.org Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com> Link: https://lkml.kernel.org/r/1507159627-127660-13-git-send-email-keescook@chromium.org
1 parent 8ede369 commit fe5c3b6

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎include/linux/kthread.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extern int tsk_fork_get_node(struct task_struct *tsk);
7575
*/
7676
struct kthread_work;
7777
typedef void (*kthread_work_func_t)(struct kthread_work *work);
78-
void kthread_delayed_work_timer_fn(unsigned long __data);
78+
void kthread_delayed_work_timer_fn(struct timer_list *t);
7979

8080
enum {
8181
KTW_FREEZABLE = 1 << 0, /* freeze during suspend */
@@ -116,8 +116,8 @@ struct kthread_delayed_work {
116116

117117
#define KTHREAD_DELAYED_WORK_INIT(dwork, fn) { \
118118
.work = KTHREAD_WORK_INIT((dwork).work, (fn)), \
119-
.timer = __TIMER_INITIALIZER(kthread_delayed_work_timer_fn, \
120-
(unsigned long)&(dwork), \
119+
.timer = __TIMER_INITIALIZER((TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\
120+
(TIMER_DATA_TYPE)&(dwork.timer), \
121121
TIMER_IRQSAFE), \
122122
}
123123

@@ -164,8 +164,8 @@ extern void __kthread_init_worker(struct kthread_worker *worker,
164164
do { \
165165
kthread_init_work(&(dwork)->work, (fn)); \
166166
__setup_timer(&(dwork)->timer, \
167-
kthread_delayed_work_timer_fn, \
168-
(unsigned long)(dwork), \
167+
(TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn,\
168+
(TIMER_DATA_TYPE)&(dwork)->timer, \
169169
TIMER_IRQSAFE); \
170170
} while (0)
171171

‎kernel/kthread.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -798,15 +798,14 @@ EXPORT_SYMBOL_GPL(kthread_queue_work);
798798
/**
799799
* kthread_delayed_work_timer_fn - callback that queues the associated kthread
800800
* delayed work when the timer expires.
801-
* @__data: pointer to the data associated with the timer
801+
* @t: pointer to the expired timer
802802
*
803803
* The format of the function is defined by struct timer_list.
804804
* It should have been called from irqsafe timer with irq already off.
805805
*/
806-
void kthread_delayed_work_timer_fn(unsigned long __data)
806+
void kthread_delayed_work_timer_fn(struct timer_list *t)
807807
{
808-
struct kthread_delayed_work *dwork =
809-
(struct kthread_delayed_work *)__data;
808+
struct kthread_delayed_work *dwork = from_timer(dwork, t, timer);
810809
struct kthread_work *work = &dwork->work;
811810
struct kthread_worker *worker = work->worker;
812811

@@ -837,8 +836,7 @@ void __kthread_queue_delayed_work(struct kthread_worker *worker,
837836
struct timer_list *timer = &dwork->timer;
838837
struct kthread_work *work = &dwork->work;
839838

840-
WARN_ON_ONCE(timer->function != kthread_delayed_work_timer_fn ||
841-
timer->data != (unsigned long)dwork);
839+
WARN_ON_ONCE(timer->function != (TIMER_FUNC_TYPE)kthread_delayed_work_timer_fn);
842840

843841
/*
844842
* If @delay is 0, queue @dwork->work immediately. This is for

0 commit comments

Comments
 (0)