From: Kees Cook <keescook@chromium.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Kees Cook <keescook@chromium.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 15/31] timer: Additional init_timer() -> setup_timer() conversions
Date: Thu, 31 Aug 2017 16:29:27 -0700 [thread overview]
Message-ID: <1504222183-61202-16-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1504222183-61202-1-git-send-email-keescook@chromium.org>
This converts several more cases of open-coded setup_timer() calls that
the setup_timer.cocci script was not able to handle itself.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
arch/arm/mach-pxa/lubbock.c | 7 ++-----
drivers/media/i2c/tvaudio.c | 4 +---
drivers/net/ethernet/chelsio/cxgb/sge.c | 11 +++++------
drivers/net/ethernet/dec/tulip/de2104x.c | 9 +++------
drivers/net/ethernet/neterion/s2io.c | 9 ++-------
drivers/s390/char/sclp_vt220.c | 4 +---
drivers/scsi/libfc/fc_fcp.c | 3 +--
drivers/tty/serial/amba-pl011.c | 5 ++---
fs/ncpfs/inode.c | 5 ++---
9 files changed, 19 insertions(+), 38 deletions(-)
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index d6159f8ef0c2..9020e18723e3 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -384,9 +384,7 @@ static struct pxafb_mach_info sharp_lm8v31 = {
static void lubbock_mmc_poll(unsigned long);
static irq_handler_t mmc_detect_int;
-static struct timer_list mmc_timer = {
- .function = lubbock_mmc_poll,
-};
+static struct timer_list mmc_timer;
static void lubbock_mmc_poll(unsigned long data)
{
@@ -421,8 +419,7 @@ static int lubbock_mci_init(struct device *dev,
{
/* detect card insert/eject */
mmc_detect_int = detect_int;
- init_timer(&mmc_timer);
- mmc_timer.data = (unsigned long) data;
+ setup_timer(&mmc_timer, lubbock_mmc_poll, (unsigned long)data);
return request_irq(LUBBOCK_SD_IRQ, lubbock_detect_int,
0, "lubbock-sd-detect", data);
}
diff --git a/drivers/media/i2c/tvaudio.c b/drivers/media/i2c/tvaudio.c
index ce86534450ac..e446bd91d408 100644
--- a/drivers/media/i2c/tvaudio.c
+++ b/drivers/media/i2c/tvaudio.c
@@ -1995,7 +1995,7 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id *
v4l2_ctrl_handler_setup(&chip->hdl);
chip->thread = NULL;
- init_timer(&chip->wt);
+ setup_timer(&chip->wt, chip_thread_wake, (unsigned long)chip);
if (desc->flags & CHIP_NEED_CHECKMODE) {
if (!desc->getrxsubchans || !desc->setaudmode) {
/* This shouldn't be happen. Warn user, but keep working
@@ -2005,8 +2005,6 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id *
return 0;
}
/* start async thread */
- chip->wt.function = chip_thread_wake;
- chip->wt.data = (unsigned long)chip;
chip->thread = kthread_run(chip_thread, chip, "%s",
client->name);
if (IS_ERR(chip->thread)) {
diff --git a/drivers/net/ethernet/chelsio/cxgb/sge.c b/drivers/net/ethernet/chelsio/cxgb/sge.c
index 75e439918700..0bc30ff625ae 100644
--- a/drivers/net/ethernet/chelsio/cxgb/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb/sge.c
@@ -2079,14 +2079,13 @@ struct sge *t1_sge_create(struct adapter *adapter, struct sge_params *p)
(unsigned long)sge);
if (is_T2(sge->adapter)) {
- init_timer(&sge->espibug_timer);
+ setup_timer(&sge->espibug_timer,
+ adapter->params.nports > 1 ?
+ espibug_workaround_t204 : espibug_workaround,
+ (unsigned long)sge->adapter);
- if (adapter->params.nports > 1) {
+ if (adapter->params.nports > 1)
tx_sched_init(sge);
- sge->espibug_timer.function = espibug_workaround_t204;
- } else
- sge->espibug_timer.function = espibug_workaround;
- sge->espibug_timer.data = (unsigned long)sge->adapter;
sge->espibug_timeout = 1;
/* for T204, every 10ms */
diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
index c87b8cc42963..14eb3706ecbe 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -1999,12 +1999,9 @@ static int de_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
de->msg_enable = (debug < 0 ? DE_DEF_MSG_ENABLE : debug);
de->board_idx = board_idx;
spin_lock_init (&de->lock);
- init_timer(&de->media_timer);
- if (de->de21040)
- de->media_timer.function = de21040_media_timer;
- else
- de->media_timer.function = de21041_media_timer;
- de->media_timer.data = (unsigned long) de;
+ setup_timer(&de->media_timer,
+ de->de21040 ? de21040_media_timer : de21041_media_timer,
+ (unsigned long)de);
netif_carrier_off(dev);
diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
index fd2ec36c6fa1..67cb4d7ff5aa 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -339,12 +339,6 @@ static const char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = {
#define S2IO_TEST_LEN ARRAY_SIZE(s2io_gstrings)
#define S2IO_STRINGS_LEN (S2IO_TEST_LEN * ETH_GSTRING_LEN)
-#define S2IO_TIMER_CONF(timer, handle, arg, exp) \
- init_timer(&timer); \
- timer.function = handle; \
- timer.data = (unsigned long)arg; \
- mod_timer(&timer, (jiffies + exp)) \
-
/* copy mac addr to def_mac_addr array */
static void do_s2io_copy_mac_addr(struct s2io_nic *sp, int offset, u64 mac_addr)
{
@@ -7222,7 +7216,8 @@ static int s2io_card_up(struct s2io_nic *sp)
return -ENODEV;
}
- S2IO_TIMER_CONF(sp->alarm_timer, s2io_alarm_handle, sp, (HZ/2));
+ setup_timer(&sp->alarm_timer, s2io_alarm_handle, (unsigned long)sp);
+ mod_timer(&sp->alarm_timer, jiffies + HZ / 2);
set_bit(__S2IO_STATE_CARD_UP, &sp->state);
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 095481d32236..2c52821011a9 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -453,8 +453,6 @@ __sclp_vt220_write(const unsigned char *buf, int count, int do_schedule,
/* Setup timer to output current console buffer after some time */
if (sclp_vt220_current_request != NULL &&
!timer_pending(&sclp_vt220_timer) && do_schedule) {
- sclp_vt220_timer.function = sclp_vt220_timeout;
- sclp_vt220_timer.data = 0UL;
sclp_vt220_timer.expires = jiffies + BUFFER_MAX_DELAY;
add_timer(&sclp_vt220_timer);
}
@@ -698,7 +696,7 @@ static int __init __sclp_vt220_init(int num_pages)
spin_lock_init(&sclp_vt220_lock);
INIT_LIST_HEAD(&sclp_vt220_empty);
INIT_LIST_HEAD(&sclp_vt220_outqueue);
- init_timer(&sclp_vt220_timer);
+ setup_timer(&sclp_vt220_timer, sclp_vt220_timeout, 0UL);
tty_port_init(&sclp_vt220_port);
sclp_vt220_current_request = NULL;
sclp_vt220_buffered_chars = 0;
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 234352da5c3c..18ca42602eb8 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -155,8 +155,7 @@ static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lport, gfp_t gfp)
fsp->lp = lport;
fsp->xfer_ddp = FC_XID_UNKNOWN;
refcount_set(&fsp->ref_cnt, 1);
- init_timer(&fsp->timer);
- fsp->timer.data = (unsigned long)fsp;
+ setup_timer(&fsp->timer, NULL, (unsigned long)fsp);
INIT_LIST_HEAD(&fsp->list);
spin_lock_init(&fsp->scsi_pkt_lock);
} else {
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 8a857bb34fbb..53913379f3d3 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1199,9 +1199,8 @@ static void pl011_dma_startup(struct uart_amba_port *uap)
dev_dbg(uap->port.dev, "could not trigger initial "
"RX DMA job, fall back to interrupt mode\n");
if (uap->dmarx.poll_rate) {
- init_timer(&(uap->dmarx.timer));
- uap->dmarx.timer.function = pl011_dma_rx_poll;
- uap->dmarx.timer.data = (unsigned long)uap;
+ setup_timer(&uap->dmarx.timer, pl011_dma_rx_poll,
+ (unsigned long)uap);
mod_timer(&uap->dmarx.timer,
jiffies +
msecs_to_jiffies(uap->dmarx.poll_rate));
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 6d0f14c86099..2f5d7d598375 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -618,7 +618,8 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
server->tx.creq = NULL;
server->rcv.creq = NULL;
- init_timer(&server->timeout_tm);
+ setup_timer(&server->timeout_tm, ncpdgram_timeout_call,
+ (unsigned long)server);
#undef NCP_PACKET_SIZE
#define NCP_PACKET_SIZE 131072
error = -ENOMEM;
@@ -650,8 +651,6 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
} else {
INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc);
INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc);
- server->timeout_tm.data = (unsigned long)server;
- server->timeout_tm.function = ncpdgram_timeout_call;
}
release_sock(sock->sk);
--
2.7.4
next prev parent reply other threads:[~2017-08-31 23:30 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-31 23:29 [PATCH 00/31] struct timer_list callback argument conversion, step 1 Kees Cook
2017-08-31 23:29 ` [PATCH 01/31] coccinelle: Improve setup_timer.cocci matching Kees Cook
2017-08-31 23:29 ` [PATCH 02/31] timer: Convert open-coded init_timer() to setup_timer() Kees Cook
2017-08-31 23:29 ` [PATCH 03/31] timer: Remove init_timer_pinned_deferrable() in favor of setup_pinned_deferrable_timer() Kees Cook
2017-08-31 23:29 ` [PATCH 04/31] timer: Remove init_timer_on_stack() in favor of setup_timer_on_stack() Kees Cook
2017-08-31 23:29 ` [PATCH 05/31] timer: Remove init_timer_pinned() in favor of setup_pinned_timer() Kees Cook
2017-08-31 23:29 ` [PATCH 06/31] timer: Remove init_timer_deferrable() in favor of setup_deferrable_timer() Kees Cook
2017-08-31 23:29 ` [PATCH 07/31] timer: Remove users of TIMER_DEFERRED_INITIALIZER Kees Cook
2017-08-31 23:29 ` [PATCH 08/31] timer: Remove users of TIMER_INITIALIZER Kees Cook
2017-08-31 23:29 ` [PATCH 09/31] timer: Remove unused static initializer macros Kees Cook
2017-08-31 23:29 ` [PATCH 10/31] timer: Remove users of expire and data arguments to DEFINE_TIMER Kees Cook
2017-08-31 23:29 ` [PATCH 11/31] timer: Remove expires and data arguments from DEFINE_TIMER Kees Cook
2017-09-01 7:26 ` Geert Uytterhoeven
2017-08-31 23:29 ` [PATCH 12/31] timer: Remove expires argument from __TIMER_INITIALIZER() Kees Cook
2017-08-31 23:29 ` [PATCH 13/31] timer: Remove meaningless .data/.function assignments Kees Cook
2017-09-01 5:09 ` Greg Kroah-Hartman
2017-09-01 17:59 ` Krzysztof Halasa
2017-09-01 20:07 ` Jens Axboe
2017-08-31 23:29 ` [PATCH 14/31] timer: Collapse cross-function single-assignment .data into setup_timer() Kees Cook
2017-08-31 23:29 ` Kees Cook [this message]
2017-08-31 23:29 ` [PATCH 16/31] usb/phy-isp1301-omap: Remove .data assignment Kees Cook
2017-08-31 23:29 ` [PATCH 17/31] media/i2c/tc358743: Initialize timer Kees Cook
2017-08-31 23:29 ` [PATCH 18/31] scsi/aic7xxx: Clean up timer usage Kees Cook
2017-08-31 23:29 ` [PATCH 19/31] timer: Remove open-coded casts for .data and .function Kees Cook
2017-09-01 0:28 ` Tyrel Datwyler
2017-09-01 0:29 ` Tyrel Datwyler
2017-08-31 23:29 ` [PATCH 20/31] net/core: Collapse redundant sk_timer callback data assignments Kees Cook
2017-08-31 23:29 ` [PATCH 21/31] s390/char/sclp: Use separate static data field with with static timer Kees Cook
2017-08-31 23:29 ` [PATCH 22/31] sparc/led: " Kees Cook
2017-08-31 23:29 ` [PATCH 23/31] mips/sgi-ip32: " Kees Cook
2017-09-01 7:04 ` Ralf Baechle
2017-09-01 22:56 ` Ralf Baechle
2017-08-31 23:29 ` [PATCH 24/31] mips/sgi-ip22: " Kees Cook
2017-09-01 6:59 ` Ralf Baechle
2017-09-01 16:57 ` Kees Cook
2017-09-01 22:56 ` Ralf Baechle
2017-08-31 23:29 ` [PATCH 25/31] net/atm/mpc: " Kees Cook
2017-08-31 23:29 ` [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional Kees Cook
2017-09-01 5:09 ` Greg Kroah-Hartman
2017-09-01 9:29 ` Ian Abbott
2017-09-01 9:38 ` Ian Abbott
2017-09-01 17:53 ` Kees Cook
2017-08-31 23:29 ` [PATCH 27/31] usb/gadget/snps_udc_core: Move timer initialization earlier Kees Cook
2017-09-03 21:12 ` Michal Nazarewicz
2017-09-06 23:23 ` Kees Cook
2017-08-31 23:29 ` [PATCH 28/31] infiniband/rdmavt: Remove redundant timer initialization Kees Cook
2017-08-31 23:29 ` [PATCH 29/31] scsi/bnx2i: Initialize timer Kees Cook
2017-08-31 23:29 ` [PATCH 30/31] appletalk: Remove unneeded synchronization Kees Cook
2017-08-31 23:29 ` [PATCH 31/31] timer: Switch to testing for .function instead of .data Kees Cook
2017-08-31 23:45 ` Dmitry Torokhov
2017-08-31 23:59 ` Kees Cook
2017-09-01 1:06 ` Dmitry Torokhov
2017-09-01 21:34 ` Jeff Kirsher
2017-09-02 13:47 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1504222183-61202-16-git-send-email-keescook@chromium.org \
--to=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®