Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1724649
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 04/31] timer: Remove init_timer_on_stack() in favor of setup_timer_on_stack() |
| Date | 2017-09-01 01:40 +0200 |
| Message-ID | <ukHe2-3XZ-11@gated-at.bofh.it> (permalink) |
| References | <ukHe1-3XZ-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Remove uses of init_timer_on_stack() with open-coded function and data
assignments that could be expressed using setup_timer_on_stack().
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/base/power/main.c | 4 +---
drivers/firewire/core-transaction.c | 2 +-
drivers/parport/ieee1284.c | 7 ++-----
drivers/s390/char/tape_std.c | 8 +++-----
drivers/s390/net/lcs.c | 7 ++-----
drivers/scsi/qla1280.c | 8 +++-----
include/linux/timer.h | 2 --
7 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index c99f8730de82..227051ef21df 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -503,11 +503,9 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
wd->dev = dev;
wd->tsk = current;
- init_timer_on_stack(timer);
+ setup_timer_on_stack(timer, dpm_watchdog_handler, (unsigned long)wd);
/* use same timeout value for both suspend and resume */
timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_TIMEOUT;
- timer->function = dpm_watchdog_handler;
- timer->data = (unsigned long)wd;
add_timer(timer);
}
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index d6a09b9cd8cc..6c428f1004f3 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -423,7 +423,7 @@ int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
struct transaction_callback_data d;
struct fw_transaction t;
- init_timer_on_stack(&t.split_timeout_timer);
+ setup_timer_on_stack(&t.split_timeout_timer, NULL, 0UL);
init_completion(&d.done);
d.payload = payload;
fw_send_request(card, &t, tcode, destination_id, generation, speed,
diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
index 74cc6dd982d2..ae289d56be8e 100644
--- a/drivers/parport/ieee1284.c
+++ b/drivers/parport/ieee1284.c
@@ -76,13 +76,10 @@ int parport_wait_event (struct parport *port, signed long timeout)
semaphore. */
return 1;
- init_timer_on_stack(&timer);
- timer.expires = jiffies + timeout;
- timer.function = timeout_waiting_on_port;
+ setup_timer_on_stack(&timer, timeout_waiting_on_port, port->number);
port_from_cookie[port->number % PARPORT_MAX] = port;
- timer.data = port->number;
- add_timer (&timer);
+ mod_timer(&timer, jiffies + timeout);
ret = down_interruptible (&port->physport->ieee1284.irq);
if (!del_timer_sync(&timer) && !ret)
/* Timed out. */
diff --git a/drivers/s390/char/tape_std.c b/drivers/s390/char/tape_std.c
index 3478e19ae194..a1213f2fadd5 100644
--- a/drivers/s390/char/tape_std.c
+++ b/drivers/s390/char/tape_std.c
@@ -70,11 +70,9 @@ tape_std_assign(struct tape_device *device)
* to another host (actually this shouldn't happen but it does).
* So we set up a timeout for this call.
*/
- init_timer_on_stack(&timeout);
- timeout.function = tape_std_assign_timeout;
- timeout.data = (unsigned long) request;
- timeout.expires = jiffies + 2 * HZ;
- add_timer(&timeout);
+ setup_timer_on_stack(&timeout, tape_std_assign_timeout,
+ (unsigned long)request);
+ mod_timer(&timeout, jiffies + 2 * HZ);
rc = tape_do_io_interruptible(device, request);
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 619da81dca70..2d7779256e6f 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -890,11 +890,8 @@ lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer,
rc = lcs_ready_buffer(&card->write, buffer);
if (rc)
return rc;
- init_timer_on_stack(&timer);
- timer.function = lcs_lancmd_timeout;
- timer.data = (unsigned long) reply;
- timer.expires = jiffies + HZ*card->lancmd_timeout;
- add_timer(&timer);
+ setup_timer_on_stack(&timer, lcs_lancmd_timeout, (unsigned long)reply);
+ mod_timer(&timer, jiffies + HZ * card->lancmd_timeout);
wait_event(reply->wait_q, reply->received);
del_timer_sync(&timer);
destroy_timer_on_stack(&timer);
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 8a29fb09db14..4f4fba222201 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -2494,11 +2494,9 @@ qla1280_mailbox_command(struct scsi_qla_host *ha, uint8_t mr, uint16_t *mb)
/* Issue set host interrupt command. */
/* set up a timer just in case we're really jammed */
- init_timer_on_stack(&timer);
- timer.expires = jiffies + 20*HZ;
- timer.data = (unsigned long)ha;
- timer.function = qla1280_mailbox_timeout;
- add_timer(&timer);
+ setup_timer_on_stack(&timer, qla1280_mailbox_timeout,
+ (unsigned long)ha);
+ mod_timer(&timer, jiffies + 20 * HZ);
spin_unlock_irq(ha->host->host_lock);
WRT_REG_WORD(®->host_cmd, HC_SET_HOST_INT);
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 1b2bb2d978de..959ba660aef0 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -132,8 +132,6 @@ static inline void init_timer_on_stack_key(struct timer_list *timer,
__init_timer((timer), TIMER_PINNED)
#define init_timer_deferrable(timer) \
__init_timer((timer), TIMER_DEFERRABLE)
-#define init_timer_on_stack(timer) \
- __init_timer_on_stack((timer), 0)
#define __setup_timer(_timer, _fn, _data, _flags) \
do { \
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/31] struct timer_list callback argument conversion, step 1 Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 01/31] coccinelle: Improve setup_timer.cocci matching Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 16/31] usb/phy-isp1301-omap: Remove .data assignment Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 10/31] timer: Remove users of expire and data arguments to DEFINE_TIMER Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 04/31] timer: Remove init_timer_on_stack() in favor of setup_timer_on_stack() Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 15/31] timer: Additional init_timer() -> setup_timer() conversions Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 09/31] timer: Remove unused static initializer macros Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 08/31] timer: Remove users of TIMER_INITIALIZER Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 03/31] timer: Remove init_timer_pinned_deferrable() in favor of setup_pinned_deferrable_timer() Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 07/31] timer: Remove users of TIMER_DEFERRED_INITIALIZER Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 12/31] timer: Remove expires argument from __TIMER_INITIALIZER() Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 18/31] scsi/aic7xxx: Clean up timer usage Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 30/31] appletalk: Remove unneeded synchronization Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 06/31] timer: Remove init_timer_deferrable() in favor of setup_deferrable_timer() Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 11/31] timer: Remove expires and data arguments from DEFINE_TIMER Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
Re: [PATCH 11/31] timer: Remove expires and data arguments from DEFINE_TIMER Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-01 09:30 +0200
[PATCH 05/31] timer: Remove init_timer_pinned() in favor of setup_pinned_timer() Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 17/31] media/i2c/tc358743: Initialize timer Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
[PATCH 24/31] mips/sgi-ip22: Use separate static data field with with static timer Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
Re: [PATCH 24/31] mips/sgi-ip22: Use separate static data field with with static timer Ralf Baechle <ralf@linux-mips.org> - 2017-09-01 09:10 +0200
Re: [PATCH 24/31] mips/sgi-ip22: Use separate static data field with with static timer Kees Cook <keescook@chromium.org> - 2017-09-01 19:00 +0200
Re: [PATCH 24/31] mips/sgi-ip22: Use separate static data field with with static timer Ralf Baechle <ralf@linux-mips.org> - 2017-09-02 01:00 +0200
[PATCH 13/31] timer: Remove meaningless .data/.function assignments Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
Re: [PATCH 13/31] timer: Remove meaningless .data/.function assignments Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-01 07:10 +0200
Re: [PATCH 13/31] timer: Remove meaningless .data/.function assignments Krzysztof Halasa <khc@pm.waw.pl> - 2017-09-01 20:10 +0200
Re: [PATCH 13/31] timer: Remove meaningless .data/.function assignments Jens Axboe <axboe@kernel.dk> - 2017-09-01 22:10 +0200
[PATCH 28/31] infiniband/rdmavt: Remove redundant timer initialization Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
[PATCH 22/31] sparc/led: Use separate static data field with with static timer Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
Re: [PATCH 31/31] timer: Switch to testing for .function instead of .data Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-09-01 01:50 +0200
Re: [PATCH 31/31] timer: Switch to testing for .function instead of .data Kees Cook <keescook@chromium.org> - 2017-09-01 02:00 +0200
Re: [PATCH 31/31] timer: Switch to testing for .function instead of .data Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-09-01 03:10 +0200
[PATCH 23/31] mips/sgi-ip32: Use separate static data field with with static timer Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
Re: [PATCH 23/31] mips/sgi-ip32: Use separate static data field with with static timer Ralf Baechle <ralf@linux-mips.org> - 2017-09-01 09:10 +0200
Re: [PATCH 23/31] mips/sgi-ip32: Use separate static data field with with static timer Ralf Baechle <ralf@linux-mips.org> - 2017-09-02 01:00 +0200
[PATCH 20/31] net/core: Collapse redundant sk_timer callback data assignments Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
[PATCH 27/31] usb/gadget/snps_udc_core: Move timer initialization earlier Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
Re: [PATCH 27/31] usb/gadget/snps_udc_core: Move timer initialization earlier Michal Nazarewicz <mina86@mina86.com> - 2017-09-03 23:20 +0200
Re: [PATCH 27/31] usb/gadget/snps_udc_core: Move timer initialization earlier Kees Cook <keescook@chromium.org> - 2017-09-07 01:30 +0200
[PATCH 21/31] s390/char/sclp: Use separate static data field with with static timer Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
[PATCH 29/31] scsi/bnx2i: Initialize timer Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
[PATCH 19/31] timer: Remove open-coded casts for .data and .function Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
Re: [PATCH 19/31] timer: Remove open-coded casts for .data and .function Tyrel Datwyler <tyreld@linux.vnet.ibm.com> - 2017-09-01 02:30 +0200
Re: [PATCH 19/31] timer: Remove open-coded casts for .data and .function Tyrel Datwyler <turtle.in.the.kernel@gmail.com> - 2017-09-01 02:30 +0200
[PATCH 25/31] net/atm/mpc: Use separate static data field with with static timer Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
[PATCH 31/31] timer: Switch to testing for .function instead of .data Kees Cook <keescook@chromium.org> - 2017-09-01 01:50 +0200
Re: [PATCH 31/31] timer: Switch to testing for .function instead of .data Jeff Kirsher <jeffrey.t.kirsher@intel.com> - 2017-09-01 23:40 +0200
Re: [PATCH 31/31] timer: Switch to testing for .function instead of .data "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-09-02 16:00 +0200
csiph-web