aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-10-04 19:26:57 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-10-05 09:01:17 -0400
commit9c6c273aa4248c60569de6ef7e7e9c7bed3cd32e (patch)
treee1a765a79a3a436212a8000d4606d1fe6aeff087 /drivers
parent1d1fe902afb380571105d05d0be3de61b81bc9a8 (diff)
timer: Remove init_timer_on_stack() in favor of timer_setup_on_stack()
Remove uses of init_timer_on_stack() with open-coded function and data assignments that could be expressed using timer_setup_on_stack(). Several were removed from the stack entirely since there was a one-to-one mapping of parent structure to timer, those are switched to using timer_setup() instead. All related callbacks were adjusted to use from_timer(). Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: linux-mips@linux-mips.org Cc: Petr Mladek <pmladek@suse.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.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: Wim Van Sebroeck <wim@iguana.be> 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: linux-scsi@vger.kernel.org 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: Michael Reed <mdr@sgi.com> Cc: Manish Chopra <manish.chopra@cavium.com> Cc: Len Brown <len.brown@intel.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: linux-pm@vger.kernel.org Cc: Lai Jiangshan <jiangshanlai@gmail.com> Cc: Tejun Heo <tj@kernel.org> 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: "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: Guenter Roeck <linux@roeck-us.net> Cc: netdev@vger.kernel.org Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> 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-4-git-send-email-keescook@chromium.org
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/power/main.c8
-rw-r--r--drivers/firewire/core-transaction.c10
-rw-r--r--drivers/parport/ieee1284.c21
-rw-r--r--drivers/s390/char/tape.h1
-rw-r--r--drivers/s390/char/tape_std.c18
-rw-r--r--drivers/s390/net/lcs.c16
-rw-r--r--drivers/s390/net/lcs.h1
-rw-r--r--drivers/scsi/qla1280.c14
-rw-r--r--drivers/scsi/qla1280.h1
9 files changed, 35 insertions, 55 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 770b1539a083..ae47b2ec84b4 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -478,9 +478,9 @@ struct dpm_watchdog {
478 * There's not much we can do here to recover so panic() to 478 * There's not much we can do here to recover so panic() to
479 * capture a crash-dump in pstore. 479 * capture a crash-dump in pstore.
480 */ 480 */
481static void dpm_watchdog_handler(unsigned long data) 481static void dpm_watchdog_handler(struct timer_list *t)
482{ 482{
483 struct dpm_watchdog *wd = (void *)data; 483 struct dpm_watchdog *wd = from_timer(wd, t, timer);
484 484
485 dev_emerg(wd->dev, "**** DPM device timeout ****\n"); 485 dev_emerg(wd->dev, "**** DPM device timeout ****\n");
486 show_stack(wd->tsk, NULL); 486 show_stack(wd->tsk, NULL);
@@ -500,11 +500,9 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
500 wd->dev = dev; 500 wd->dev = dev;
501 wd->tsk = current; 501 wd->tsk = current;
502 502
503 init_timer_on_stack(timer); 503 timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
504 /* use same timeout value for both suspend and resume */ 504 /* use same timeout value for both suspend and resume */
505 timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_TIMEOUT; 505 timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_TIMEOUT;
506 timer->function = dpm_watchdog_handler;
507 timer->data = (unsigned long)wd;
508 add_timer(timer); 506 add_timer(timer);
509} 507}
510 508
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index d6a09b9cd8cc..4372f9e4b0da 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -137,9 +137,9 @@ int fw_cancel_transaction(struct fw_card *card,
137} 137}
138EXPORT_SYMBOL(fw_cancel_transaction); 138EXPORT_SYMBOL(fw_cancel_transaction);
139 139
140static void split_transaction_timeout_callback(unsigned long data) 140static void split_transaction_timeout_callback(struct timer_list *timer)
141{ 141{
142 struct fw_transaction *t = (struct fw_transaction *)data; 142 struct fw_transaction *t = from_timer(t, timer, split_timeout_timer);
143 struct fw_card *card = t->card; 143 struct fw_card *card = t->card;
144 unsigned long flags; 144 unsigned long flags;
145 145
@@ -373,8 +373,8 @@ void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode,
373 t->tlabel = tlabel; 373 t->tlabel = tlabel;
374 t->card = card; 374 t->card = card;
375 t->is_split_transaction = false; 375 t->is_split_transaction = false;
376 setup_timer(&t->split_timeout_timer, 376 timer_setup(&t->split_timeout_timer,
377 split_transaction_timeout_callback, (unsigned long)t); 377 split_transaction_timeout_callback, 0);
378 t->callback = callback; 378 t->callback = callback;
379 t->callback_data = callback_data; 379 t->callback_data = callback_data;
380 380
@@ -423,7 +423,7 @@ int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
423 struct transaction_callback_data d; 423 struct transaction_callback_data d;
424 struct fw_transaction t; 424 struct fw_transaction t;
425 425
426 init_timer_on_stack(&t.split_timeout_timer); 426 timer_setup_on_stack(&t.split_timeout_timer, NULL, 0);
427 init_completion(&d.done); 427 init_completion(&d.done);
428 d.payload = payload; 428 d.payload = payload;
429 fw_send_request(card, &t, tcode, destination_id, generation, speed, 429 fw_send_request(card, &t, tcode, destination_id, generation, speed,
diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
index 74cc6dd982d2..2d1a5c737c6e 100644
--- a/drivers/parport/ieee1284.c
+++ b/drivers/parport/ieee1284.c
@@ -44,10 +44,11 @@ static void parport_ieee1284_wakeup (struct parport *port)
44 up (&port->physport->ieee1284.irq); 44 up (&port->physport->ieee1284.irq);
45} 45}
46 46
47static struct parport *port_from_cookie[PARPORT_MAX]; 47static void timeout_waiting_on_port (struct timer_list *t)
48static void timeout_waiting_on_port (unsigned long cookie)
49{ 48{
50 parport_ieee1284_wakeup (port_from_cookie[cookie % PARPORT_MAX]); 49 struct parport *port = from_timer(port, t, timer);
50
51 parport_ieee1284_wakeup (port);
51} 52}
52 53
53/** 54/**
@@ -69,27 +70,19 @@ static void timeout_waiting_on_port (unsigned long cookie)
69int parport_wait_event (struct parport *port, signed long timeout) 70int parport_wait_event (struct parport *port, signed long timeout)
70{ 71{
71 int ret; 72 int ret;
72 struct timer_list timer;
73 73
74 if (!port->physport->cad->timeout) 74 if (!port->physport->cad->timeout)
75 /* Zero timeout is special, and we can't down() the 75 /* Zero timeout is special, and we can't down() the
76 semaphore. */ 76 semaphore. */
77 return 1; 77 return 1;
78 78
79 init_timer_on_stack(&timer); 79 timer_setup(&port->timer, timeout_waiting_on_port, 0);
80 timer.expires = jiffies + timeout; 80 mod_timer(&port->timer, jiffies + timeout);
81 timer.function = timeout_waiting_on_port;
82 port_from_cookie[port->number % PARPORT_MAX] = port;
83 timer.data = port->number;
84
85 add_timer (&timer);
86 ret = down_interruptible (&port->physport->ieee1284.irq); 81 ret = down_interruptible (&port->physport->ieee1284.irq);
87 if (!del_timer_sync(&timer) && !ret) 82 if (!del_timer_sync(&port->timer) && !ret)
88 /* Timed out. */ 83 /* Timed out. */
89 ret = 1; 84 ret = 1;
90 85
91 destroy_timer_on_stack(&timer);
92
93 return ret; 86 return ret;
94} 87}
95 88
diff --git a/drivers/s390/char/tape.h b/drivers/s390/char/tape.h
index ea664dd4f56d..52fbcd9c3cf8 100644
--- a/drivers/s390/char/tape.h
+++ b/drivers/s390/char/tape.h
@@ -128,6 +128,7 @@ struct tape_request {
128 int options; /* options for execution. */ 128 int options; /* options for execution. */
129 int retries; /* retry counter for error recovery. */ 129 int retries; /* retry counter for error recovery. */
130 int rescnt; /* residual count from devstat. */ 130 int rescnt; /* residual count from devstat. */
131 struct timer_list timer; /* timer for std_assign_timeout(). */
131 132
132 /* Callback for delivering final status. */ 133 /* Callback for delivering final status. */
133 void (*callback)(struct tape_request *, void *); 134 void (*callback)(struct tape_request *, void *);
diff --git a/drivers/s390/char/tape_std.c b/drivers/s390/char/tape_std.c
index 3478e19ae194..cd204abdc0bc 100644
--- a/drivers/s390/char/tape_std.c
+++ b/drivers/s390/char/tape_std.c
@@ -32,14 +32,12 @@
32 * tape_std_assign 32 * tape_std_assign
33 */ 33 */
34static void 34static void
35tape_std_assign_timeout(unsigned long data) 35tape_std_assign_timeout(struct timer_list *t)
36{ 36{
37 struct tape_request * request; 37 struct tape_request * request = from_timer(request, t, timer);
38 struct tape_device * device; 38 struct tape_device * device = request->device;
39 int rc; 39 int rc;
40 40
41 request = (struct tape_request *) data;
42 device = request->device;
43 BUG_ON(!device); 41 BUG_ON(!device);
44 42
45 DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n", 43 DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
@@ -70,16 +68,12 @@ tape_std_assign(struct tape_device *device)
70 * to another host (actually this shouldn't happen but it does). 68 * to another host (actually this shouldn't happen but it does).
71 * So we set up a timeout for this call. 69 * So we set up a timeout for this call.
72 */ 70 */
73 init_timer_on_stack(&timeout); 71 timer_setup(&request->timer, tape_std_assign_timeout, 0);
74 timeout.function = tape_std_assign_timeout; 72 mod_timer(&timeout, jiffies + 2 * HZ);
75 timeout.data = (unsigned long) request;
76 timeout.expires = jiffies + 2 * HZ;
77 add_timer(&timeout);
78 73
79 rc = tape_do_io_interruptible(device, request); 74 rc = tape_do_io_interruptible(device, request);
80 75
81 del_timer_sync(&timeout); 76 del_timer_sync(&request->timer);
82 destroy_timer_on_stack(&timeout);
83 77
84 if (rc != 0) { 78 if (rc != 0) {
85 DBF_EVENT(3, "%08x: assign failed - device might be busy\n", 79 DBF_EVENT(3, "%08x: assign failed - device might be busy\n",
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index d01b5c2a7760..21bba406d5be 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -834,9 +834,10 @@ lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd)
834 * Emit buffer of a lan command. 834 * Emit buffer of a lan command.
835 */ 835 */
836static void 836static void
837lcs_lancmd_timeout(unsigned long data) 837lcs_lancmd_timeout(struct timer_list *t)
838{ 838{
839 struct lcs_reply *reply, *list_reply, *r; 839 struct lcs_reply *reply = from_timer(reply, t, timer);
840 struct lcs_reply *list_reply, *r;
840 unsigned long flags; 841 unsigned long flags;
841 842
842 LCS_DBF_TEXT(4, trace, "timeout"); 843 LCS_DBF_TEXT(4, trace, "timeout");
@@ -864,7 +865,6 @@ lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
864{ 865{
865 struct lcs_reply *reply; 866 struct lcs_reply *reply;
866 struct lcs_cmd *cmd; 867 struct lcs_cmd *cmd;
867 struct timer_list timer;
868 unsigned long flags; 868 unsigned long flags;
869 int rc; 869 int rc;
870 870
@@ -885,14 +885,10 @@ lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
885 rc = lcs_ready_buffer(&card->write, buffer); 885 rc = lcs_ready_buffer(&card->write, buffer);
886 if (rc) 886 if (rc)
887 return rc; 887 return rc;
888 init_timer_on_stack(&timer); 888 timer_setup(&reply->timer, lcs_lancmd_timeout, 0);
889 timer.function = lcs_lancmd_timeout; 889 mod_timer(&reply->timer, jiffies + HZ * card->lancmd_timeout);
890 timer.data = (unsigned long) reply;
891 timer.expires = jiffies + HZ*card->lancmd_timeout;
892 add_timer(&timer);
893 wait_event(reply->wait_q, reply->received); 890 wait_event(reply->wait_q, reply->received);
894 del_timer_sync(&timer); 891 del_timer_sync(&reply->timer);
895 destroy_timer_on_stack(&timer);
896 LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc); 892 LCS_DBF_TEXT_(4, trace, "rc:%d",reply->rc);
897 rc = reply->rc; 893 rc = reply->rc;
898 lcs_put_reply(reply); 894 lcs_put_reply(reply);
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index 150fcb4cebc3..d44fb8d9378f 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -275,6 +275,7 @@ struct lcs_reply {
275 void (*callback)(struct lcs_card *, struct lcs_cmd *); 275 void (*callback)(struct lcs_card *, struct lcs_cmd *);
276 wait_queue_head_t wait_q; 276 wait_queue_head_t wait_q;
277 struct lcs_card *card; 277 struct lcs_card *card;
278 struct timer_list timer;
278 int received; 279 int received;
279 int rc; 280 int rc;
280}; 281};
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 8a29fb09db14..390775d5c918 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -758,9 +758,9 @@ enum action {
758}; 758};
759 759
760 760
761static void qla1280_mailbox_timeout(unsigned long __data) 761static void qla1280_mailbox_timeout(struct timer_list *t)
762{ 762{
763 struct scsi_qla_host *ha = (struct scsi_qla_host *)__data; 763 struct scsi_qla_host *ha = from_timer(ha, t, mailbox_timer);
764 struct device_reg __iomem *reg; 764 struct device_reg __iomem *reg;
765 reg = ha->iobase; 765 reg = ha->iobase;
766 766
@@ -2465,7 +2465,6 @@ qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
2465 uint16_t __iomem *mptr; 2465 uint16_t __iomem *mptr;
2466 uint16_t data; 2466 uint16_t data;
2467 DECLARE_COMPLETION_ONSTACK(wait); 2467 DECLARE_COMPLETION_ONSTACK(wait);
2468 struct timer_list timer;
2469 2468
2470 ENTER("qla1280_mailbox_command"); 2469 ENTER("qla1280_mailbox_command");
2471 2470
@@ -2494,18 +2493,15 @@ qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
2494 /* Issue set host interrupt command. */ 2493 /* Issue set host interrupt command. */
2495 2494
2496 /* set up a timer just in case we're really jammed */ 2495 /* set up a timer just in case we're really jammed */
2497 init_timer_on_stack(&timer); 2496 timer_setup(&ha->mailbox_timer, qla1280_mailbox_timeout, 0);
2498 timer.expires = jiffies + 20*HZ; 2497 mod_timer(&ha->mailbox_timer, jiffies + 20 * HZ);
2499 timer.data = (unsigned long)ha;
2500 timer.function = qla1280_mailbox_timeout;
2501 add_timer(&timer);
2502 2498
2503 spin_unlock_irq(ha->host->host_lock); 2499 spin_unlock_irq(ha->host->host_lock);
2504 WRT_REG_WORD(&reg->host_cmd, HC_SET_HOST_INT); 2500 WRT_REG_WORD(&reg->host_cmd, HC_SET_HOST_INT);
2505 data = qla1280_debounce_register(&reg->istatus); 2501 data = qla1280_debounce_register(&reg->istatus);
2506 2502
2507 wait_for_completion(&wait); 2503 wait_for_completion(&wait);
2508 del_timer_sync(&timer); 2504 del_timer_sync(&ha->mailbox_timer);
2509 2505
2510 spin_lock_irq(ha->host->host_lock); 2506 spin_lock_irq(ha->host->host_lock);
2511 2507
diff --git a/drivers/scsi/qla1280.h b/drivers/scsi/qla1280.h
index 834884b9eed5..1522aca2c8c8 100644
--- a/drivers/scsi/qla1280.h
+++ b/drivers/scsi/qla1280.h
@@ -1055,6 +1055,7 @@ struct scsi_qla_host {
1055 struct list_head done_q; /* Done queue */ 1055 struct list_head done_q; /* Done queue */
1056 1056
1057 struct completion *mailbox_wait; 1057 struct completion *mailbox_wait;
1058 struct timer_list mailbox_timer;
1058 1059
1059 volatile struct { 1060 volatile struct {
1060 uint32_t online:1; /* 0 */ 1061 uint32_t online:1; /* 0 */