diff options
author | Kees Cook <keescook@chromium.org> | 2017-10-16 14:43:17 -0700 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2017-11-21 15:57:07 -0800 |
commit | e99e88a9d2b067465adaa9c111ada99a041bef9a (patch) | |
tree | 6589bfe737740cb005070d92a364a7e042670c81 /drivers/tty | |
parent | b9eaf18722221ef8b2bd6a67240ebe668622152a (diff) | |
download | linux-e99e88a9d2b067465adaa9c111ada99a041bef9a.tar.gz |
treewide: setup_timer() -> timer_setup()
This converts all remaining cases of the old setup_timer() API into using
timer_setup(), where the callback argument is the structure already
holding the struct timer_list. These should have no behavioral changes,
since they just change which pointer is passed into the callback with
the same available pointers after conversion. It handles the following
examples, in addition to some other variations.
Casting from unsigned long:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
setup_timer(&ptr->my_timer, my_callback, ptr);
and forced object casts:
void my_callback(struct something *ptr)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, (unsigned long)ptr);
become:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
Direct function assignments:
void my_callback(unsigned long data)
{
struct something *ptr = (struct something *)data;
...
}
...
ptr->my_timer.function = my_callback;
have a temporary cast added, along with converting the args:
void my_callback(struct timer_list *t)
{
struct something *ptr = from_timer(ptr, t, my_timer);
...
}
...
ptr->my_timer.function = (TIMER_FUNC_TYPE)my_callback;
And finally, callbacks without a data assignment:
void my_callback(unsigned long data)
{
...
}
...
setup_timer(&ptr->my_timer, my_callback, 0);
have their argument renamed to verify they're unused during conversion:
void my_callback(struct timer_list *unused)
{
...
}
...
timer_setup(&ptr->my_timer, my_callback, 0);
The conversion is done with the following Coccinelle script:
spatch --very-quiet --all-includes --include-headers \
-I ./arch/x86/include -I ./arch/x86/include/generated \
-I ./include -I ./arch/x86/include/uapi \
-I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/kconfig.h \
--dir . \
--cocci-file ~/src/data/timer_setup.cocci
@fix_address_of@
expression e;
@@
setup_timer(
-&(e)
+&e
, ...)
// Update any raw setup_timer() usages that have a NULL callback, but
// would otherwise match change_timer_function_usage, since the latter
// will update all function assignments done in the face of a NULL
// function initialization in setup_timer().
@change_timer_function_usage_NULL@
expression _E;
identifier _timer;
type _cast_data;
@@
(
-setup_timer(&_E->_timer, NULL, _E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E->_timer, NULL, (_cast_data)_E);
+timer_setup(&_E->_timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, &_E);
+timer_setup(&_E._timer, NULL, 0);
|
-setup_timer(&_E._timer, NULL, (_cast_data)&_E);
+timer_setup(&_E._timer, NULL, 0);
)
@change_timer_function_usage@
expression _E;
identifier _timer;
struct timer_list _stl;
identifier _callback;
type _cast_func, _cast_data;
@@
(
-setup_timer(&_E->_timer, _callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, &_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, _E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, &_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)_E);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, (_cast_func)&_callback, (_cast_data)&_E);
+timer_setup(&_E._timer, _callback, 0);
|
_E->_timer@_stl.function = _callback;
|
_E->_timer@_stl.function = &_callback;
|
_E->_timer@_stl.function = (_cast_func)_callback;
|
_E->_timer@_stl.function = (_cast_func)&_callback;
|
_E._timer@_stl.function = _callback;
|
_E._timer@_stl.function = &_callback;
|
_E._timer@_stl.function = (_cast_func)_callback;
|
_E._timer@_stl.function = (_cast_func)&_callback;
)
// callback(unsigned long arg)
@change_callback_handle_cast
depends on change_timer_function_usage@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
identifier _handle;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
(
... when != _origarg
_handletype *_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(_handletype *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
|
... when != _origarg
_handletype *_handle;
... when != _handle
_handle =
-(void *)_origarg;
+from_timer(_handle, t, _timer);
... when != _origarg
)
}
// callback(unsigned long arg) without existing variable
@change_callback_handle_cast_no_arg
depends on change_timer_function_usage &&
!change_callback_handle_cast@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _origtype;
identifier _origarg;
type _handletype;
@@
void _callback(
-_origtype _origarg
+struct timer_list *t
)
{
+ _handletype *_origarg = from_timer(_origarg, t, _timer);
+
... when != _origarg
- (_handletype *)_origarg
+ _origarg
... when != _origarg
}
// Avoid already converted callbacks.
@match_callback_converted
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier t;
@@
void _callback(struct timer_list *t)
{ ... }
// callback(struct something *handle)
@change_callback_handle_arg
depends on change_timer_function_usage &&
!match_callback_converted &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
@@
void _callback(
-_handletype *_handle
+struct timer_list *t
)
{
+ _handletype *_handle = from_timer(_handle, t, _timer);
...
}
// If change_callback_handle_arg ran on an empty function, remove
// the added handler.
@unchange_callback_handle_arg
depends on change_timer_function_usage &&
change_callback_handle_arg@
identifier change_timer_function_usage._callback;
identifier change_timer_function_usage._timer;
type _handletype;
identifier _handle;
identifier t;
@@
void _callback(struct timer_list *t)
{
- _handletype *_handle = from_timer(_handle, t, _timer);
}
// We only want to refactor the setup_timer() data argument if we've found
// the matching callback. This undoes changes in change_timer_function_usage.
@unchange_timer_function_usage
depends on change_timer_function_usage &&
!change_callback_handle_cast &&
!change_callback_handle_cast_no_arg &&
!change_callback_handle_arg@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type change_timer_function_usage._cast_data;
@@
(
-timer_setup(&_E->_timer, _callback, 0);
+setup_timer(&_E->_timer, _callback, (_cast_data)_E);
|
-timer_setup(&_E._timer, _callback, 0);
+setup_timer(&_E._timer, _callback, (_cast_data)&_E);
)
// If we fixed a callback from a .function assignment, fix the
// assignment cast now.
@change_timer_function_assignment
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression change_timer_function_usage._E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_func;
typedef TIMER_FUNC_TYPE;
@@
(
_E->_timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E->_timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-&_callback;
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)_callback
+(TIMER_FUNC_TYPE)_callback
;
|
_E._timer.function =
-(_cast_func)&_callback
+(TIMER_FUNC_TYPE)_callback
;
)
// Sometimes timer functions are called directly. Replace matched args.
@change_timer_function_calls
depends on change_timer_function_usage &&
(change_callback_handle_cast ||
change_callback_handle_cast_no_arg ||
change_callback_handle_arg)@
expression _E;
identifier change_timer_function_usage._timer;
identifier change_timer_function_usage._callback;
type _cast_data;
@@
_callback(
(
-(_cast_data)_E
+&_E->_timer
|
-(_cast_data)&_E
+&_E._timer
|
-_E
+&_E->_timer
)
)
// If a timer has been configured without a data argument, it can be
// converted without regard to the callback argument, since it is unused.
@match_timer_function_unused_data@
expression _E;
identifier _timer;
identifier _callback;
@@
(
-setup_timer(&_E->_timer, _callback, 0);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0L);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E->_timer, _callback, 0UL);
+timer_setup(&_E->_timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0L);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_E._timer, _callback, 0UL);
+timer_setup(&_E._timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0L);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(&_timer, _callback, 0UL);
+timer_setup(&_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0L);
+timer_setup(_timer, _callback, 0);
|
-setup_timer(_timer, _callback, 0UL);
+timer_setup(_timer, _callback, 0);
)
@change_callback_unused_data
depends on match_timer_function_unused_data@
identifier match_timer_function_unused_data._callback;
type _origtype;
identifier _origarg;
@@
void _callback(
-_origtype _origarg
+struct timer_list *unused
)
{
... when != _origarg
}
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/ipwireless/hardware.c | 11 | ||||
-rw-r--r-- | drivers/tty/n_gsm.c | 12 | ||||
-rw-r--r-- | drivers/tty/n_r3964.c | 8 | ||||
-rw-r--r-- | drivers/tty/serial/crisv10.c | 4 | ||||
-rw-r--r-- | drivers/tty/serial/fsl_lpuart.c | 7 | ||||
-rw-r--r-- | drivers/tty/serial/ifx6x60.c | 7 | ||||
-rw-r--r-- | drivers/tty/serial/imx.c | 6 | ||||
-rw-r--r-- | drivers/tty/serial/kgdb_nmi.c | 6 | ||||
-rw-r--r-- | drivers/tty/serial/max3100.c | 7 | ||||
-rw-r--r-- | drivers/tty/serial/mux.c | 4 | ||||
-rw-r--r-- | drivers/tty/serial/pnx8xxx_uart.c | 7 | ||||
-rw-r--r-- | drivers/tty/serial/sa1100.c | 7 | ||||
-rw-r--r-- | drivers/tty/serial/sh-sci.c | 16 | ||||
-rw-r--r-- | drivers/tty/serial/sn_console.c | 6 | ||||
-rw-r--r-- | drivers/tty/synclink.c | 8 | ||||
-rw-r--r-- | drivers/tty/synclink_gt.c | 16 | ||||
-rw-r--r-- | drivers/tty/synclinkmp.c | 17 |
17 files changed, 70 insertions, 79 deletions
diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c index a6b8240af6cd..b0baa4ce10f9 100644 --- a/drivers/tty/ipwireless/hardware.c +++ b/drivers/tty/ipwireless/hardware.c @@ -33,7 +33,7 @@ static void handle_received_SETUP_packet(struct ipw_hardware *ipw, unsigned int address, const unsigned char *data, int len, int is_last); -static void ipwireless_setup_timer(unsigned long data); +static void ipwireless_setup_timer(struct timer_list *t); static void handle_received_CTRL_packet(struct ipw_hardware *hw, unsigned int channel_idx, const unsigned char *data, int len); @@ -1635,8 +1635,7 @@ struct ipw_hardware *ipwireless_hardware_create(void) spin_lock_init(&hw->lock); tasklet_init(&hw->tasklet, ipwireless_do_tasklet, (unsigned long) hw); INIT_WORK(&hw->work_rx, ipw_receive_data_work); - setup_timer(&hw->setup_timer, ipwireless_setup_timer, - (unsigned long) hw); + timer_setup(&hw->setup_timer, ipwireless_setup_timer, 0); return hw; } @@ -1670,12 +1669,12 @@ void ipwireless_init_hardware_v2_v3(struct ipw_hardware *hw) hw->init_loops = 0; printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": waiting for card to start up...\n"); - ipwireless_setup_timer((unsigned long) hw); + ipwireless_setup_timer(&hw->setup_timer); } -static void ipwireless_setup_timer(unsigned long data) +static void ipwireless_setup_timer(struct timer_list *t) { - struct ipw_hardware *hw = (struct ipw_hardware *) data; + struct ipw_hardware *hw = from_timer(hw, t, setup_timer); hw->init_loops++; diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 3a39eb685c69..5131bdc9e765 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1310,9 +1310,9 @@ static void gsm_control_transmit(struct gsm_mux *gsm, struct gsm_control *ctrl) * gsm->pending_cmd will be NULL and we just let the timer expire. */ -static void gsm_control_retransmit(unsigned long data) +static void gsm_control_retransmit(struct timer_list *t) { - struct gsm_mux *gsm = (struct gsm_mux *)data; + struct gsm_mux *gsm = from_timer(gsm, t, t2_timer); struct gsm_control *ctrl; unsigned long flags; spin_lock_irqsave(&gsm->control_lock, flags); @@ -1453,9 +1453,9 @@ static void gsm_dlci_open(struct gsm_dlci *dlci) * end will get a DM response) */ -static void gsm_dlci_t1(unsigned long data) +static void gsm_dlci_t1(struct timer_list *t) { - struct gsm_dlci *dlci = (struct gsm_dlci *)data; + struct gsm_dlci *dlci = from_timer(dlci, t, t1); struct gsm_mux *gsm = dlci->gsm; switch (dlci->state) { @@ -1634,7 +1634,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr) } skb_queue_head_init(&dlci->skb_list); - setup_timer(&dlci->t1, gsm_dlci_t1, (unsigned long)dlci); + timer_setup(&dlci->t1, gsm_dlci_t1, 0); tty_port_init(&dlci->port); dlci->port.ops = &gsm_port_ops; dlci->gsm = gsm; @@ -2088,7 +2088,7 @@ static int gsm_activate_mux(struct gsm_mux *gsm) struct gsm_dlci *dlci; int i = 0; - setup_timer(&gsm->t2_timer, gsm_control_retransmit, (unsigned long)gsm); + timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0); init_waitqueue_head(&gsm->event); spin_lock_init(&gsm->control_lock); spin_lock_init(&gsm->tx_lock); diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c index 9f246d4db3ca..30bb0900cd2f 100644 --- a/drivers/tty/n_r3964.c +++ b/drivers/tty/n_r3964.c @@ -115,7 +115,7 @@ static void retry_transmit(struct r3964_info *pInfo); static void transmit_block(struct r3964_info *pInfo); static void receive_char(struct r3964_info *pInfo, const unsigned char c); static void receive_error(struct r3964_info *pInfo, const char flag); -static void on_timeout(unsigned long priv); +static void on_timeout(struct timer_list *t); static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg); static int read_telegram(struct r3964_info *pInfo, struct pid *pid, unsigned char __user * buf); @@ -688,9 +688,9 @@ static void receive_error(struct r3964_info *pInfo, const char flag) } } -static void on_timeout(unsigned long priv) +static void on_timeout(struct timer_list *t) { - struct r3964_info *pInfo = (void *)priv; + struct r3964_info *pInfo = from_timer(pInfo, t, tmr); switch (pInfo->state) { case R3964_TX_REQUEST: @@ -993,7 +993,7 @@ static int r3964_open(struct tty_struct *tty) tty->disc_data = pInfo; tty->receive_room = 65536; - setup_timer(&pInfo->tmr, on_timeout, (unsigned long)pInfo); + timer_setup(&pInfo->tmr, on_timeout, 0); return 0; } diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index 1421804975e0..c9458a033e3c 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c @@ -2059,7 +2059,7 @@ static void flush_timeout_function(unsigned long data) static struct timer_list flush_timer; static void -timed_flush_handler(unsigned long ptr) +timed_flush_handler(struct timer_list *unused) { struct e100_serial *info; int i; @@ -4137,7 +4137,7 @@ static int __init rs_init(void) /* Setup the timed flush handler system */ #if !defined(CONFIG_ETRAX_SERIAL_FAST_TIMER) - setup_timer(&flush_timer, timed_flush_handler, 0); + timer_setup(&flush_timer, timed_flush_handler, 0); mod_timer(&flush_timer, jiffies + 5); #endif diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index c84e6f0db54e..1c4d3f387138 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -966,9 +966,9 @@ static void lpuart_dma_rx_complete(void *arg) lpuart_copy_rx_to_tty(sport); } -static void lpuart_timer_func(unsigned long data) +static void lpuart_timer_func(struct timer_list *t) { - struct lpuart_port *sport = (struct lpuart_port *)data; + struct lpuart_port *sport = from_timer(sport, t, lpuart_timer); lpuart_copy_rx_to_tty(sport); } @@ -1263,8 +1263,7 @@ static void lpuart32_setup_watermark(struct lpuart_port *sport) static void rx_dma_timer_init(struct lpuart_port *sport) { - setup_timer(&sport->lpuart_timer, lpuart_timer_func, - (unsigned long)sport); + timer_setup(&sport->lpuart_timer, lpuart_timer_func, 0); sport->lpuart_timer.expires = jiffies + sport->dma_rx_timeout; add_timer(&sport->lpuart_timer); } diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c index 473f4f81d690..ffefd218761e 100644 --- a/drivers/tty/serial/ifx6x60.c +++ b/drivers/tty/serial/ifx6x60.c @@ -263,9 +263,9 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev) * The SPI has timed out: hang up the tty. Users will then see a hangup * and error events. */ -static void ifx_spi_timeout(unsigned long arg) +static void ifx_spi_timeout(struct timer_list *t) { - struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg; + struct ifx_spi_device *ifx_dev = from_timer(ifx_dev, t, spi_timer); dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***"); tty_port_tty_hangup(&ifx_dev->tty_port, false); @@ -1016,8 +1016,7 @@ static int ifx_spi_spi_probe(struct spi_device *spi) spin_lock_init(&ifx_dev->write_lock); spin_lock_init(&ifx_dev->power_lock); ifx_dev->power_status = 0; - setup_timer(&ifx_dev->spi_timer, ifx_spi_timeout, - (unsigned long)ifx_dev); + timer_setup(&ifx_dev->spi_timer, ifx_spi_timeout, 0); ifx_dev->modem = pl_data->modem_type; ifx_dev->use_dma = pl_data->use_dma; ifx_dev->max_hz = pl_data->max_hz; diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index a67a606c38eb..e4b3d9123a03 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -906,9 +906,9 @@ static void imx_break_ctl(struct uart_port *port, int break_state) * This is our per-port timeout handler, for checking the * modem status signals. */ -static void imx_timeout(unsigned long data) +static void imx_timeout(struct timer_list *t) { - struct imx_port *sport = (struct imx_port *)data; + struct imx_port *sport = from_timer(sport, t, timer); unsigned long flags; if (sport->port.state) { @@ -2082,7 +2082,7 @@ static int serial_imx_probe(struct platform_device *pdev) sport->port.rs485_config = imx_rs485_config; sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND; sport->port.flags = UPF_BOOT_AUTOCONF; - setup_timer(&sport->timer, imx_timeout, (unsigned long)sport); + timer_setup(&sport->timer, imx_timeout, 0); sport->gpios = mctrl_gpio_init(&sport->port, 0); if (IS_ERR(sport->gpios)) diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c index ed2b03058627..4029272891f9 100644 --- a/drivers/tty/serial/kgdb_nmi.c +++ b/drivers/tty/serial/kgdb_nmi.c @@ -188,9 +188,9 @@ bool kgdb_nmi_poll_knock(void) * The tasklet is cheap, it does not cause wakeups when reschedules itself, * instead it waits for the next tick. */ -static void kgdb_nmi_tty_receiver(unsigned long data) +static void kgdb_nmi_tty_receiver(struct timer_list *t) { - struct kgdb_nmi_tty_priv *priv = (void *)data; + struct kgdb_nmi_tty_priv *priv = from_timer(priv, t, timer); char ch; priv->timer.expires = jiffies + (HZ/100); @@ -241,7 +241,7 @@ static int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty) return -ENOMEM; INIT_KFIFO(priv->fifo); - setup_timer(&priv->timer, kgdb_nmi_tty_receiver, (unsigned long)priv); + timer_setup(&priv->timer, kgdb_nmi_tty_receiver, 0); tty_port_init(&priv->port); priv->port.ops = &kgdb_nmi_tty_port_ops; tty->driver_data = priv; diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c index 27d6049eb6a9..371569a0fd00 100644 --- a/drivers/tty/serial/max3100.c +++ b/drivers/tty/serial/max3100.c @@ -178,9 +178,9 @@ static void max3100_dowork(struct max3100_port *s) queue_work(s->workqueue, &s->work); } -static void max3100_timeout(unsigned long data) +static void max3100_timeout(struct timer_list *t) { - struct max3100_port *s = (struct max3100_port *)data; + struct max3100_port *s = from_timer(s, t, timer); if (s->port.state) { max3100_dowork(s); @@ -780,8 +780,7 @@ static int max3100_probe(struct spi_device *spi) max3100s[i]->poll_time = 1; max3100s[i]->max3100_hw_suspend = pdata->max3100_hw_suspend; max3100s[i]->minor = i; - setup_timer(&max3100s[i]->timer, max3100_timeout, - (unsigned long)max3100s[i]); + timer_setup(&max3100s[i]->timer, max3100_timeout, 0); dev_dbg(&spi->dev, "%s: adding port %d\n", __func__, i); max3100s[i]->port.irq = max3100s[i]->irq; diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c index 3b74369c262f..00ce31e8d19a 100644 --- a/drivers/tty/serial/mux.c +++ b/drivers/tty/serial/mux.c @@ -371,7 +371,7 @@ static int mux_verify_port(struct uart_port *port, struct serial_struct *ser) * * This function periodically polls the Serial MUX to check for new data. */ -static void mux_poll(unsigned long unused) +static void mux_poll(struct timer_list *unused) { int i; @@ -572,7 +572,7 @@ static int __init mux_init(void) if(port_cnt > 0) { /* Start the Mux timer */ - setup_timer(&mux_timer, mux_poll, 0UL); + timer_setup(&mux_timer, mux_poll, 0); mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY); #ifdef CONFIG_SERIAL_MUX_CONSOLE diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c index f8812389b8a8..223a9499104e 100644 --- a/drivers/tty/serial/pnx8xxx_uart.c +++ b/drivers/tty/serial/pnx8xxx_uart.c @@ -103,9 +103,9 @@ static void pnx8xxx_mctrl_check(struct pnx8xxx_port *sport) * This is our per-port timeout handler, for checking the * modem status signals. */ -static void pnx8xxx_timeout(unsigned long data) +static void pnx8xxx_timeout(struct timer_list *t) { - struct pnx8xxx_port *sport = (struct pnx8xxx_port *)data; + struct pnx8xxx_port *sport = from_timer(sport, t, timer); unsigned long flags; if (sport->port.state) { @@ -662,8 +662,7 @@ static void __init pnx8xxx_init_ports(void) first = 0; for (i = 0; i < NR_PORTS; i++) { - setup_timer(&pnx8xxx_ports[i].timer, pnx8xxx_timeout, - (unsigned long)&pnx8xxx_ports[i]); + timer_setup(&pnx8xxx_ports[i].timer, pnx8xxx_timeout, 0); pnx8xxx_ports[i].port.ops = &pnx8xxx_pops; } } diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c index 4e3f169b30cf..a399772be3fc 100644 --- a/drivers/tty/serial/sa1100.c +++ b/drivers/tty/serial/sa1100.c @@ -110,9 +110,9 @@ static void sa1100_mctrl_check(struct sa1100_port *sport) * This is our per-port timeout handler, for checking the * modem status signals. */ -static void sa1100_timeout(unsigned long data) +static void sa1100_timeout(struct timer_list *t) { - struct sa1100_port *sport = (struct sa1100_port *)data; + struct sa1100_port *sport = from_timer(sport, t, timer); unsigned long flags; if (sport->port.state) { @@ -627,8 +627,7 @@ static void __init sa1100_init_ports(void) sa1100_ports[i].port.fifosize = 8; sa1100_ports[i].port.line = i; sa1100_ports[i].port.iotype = UPIO_MEM; - setup_timer(&sa1100_ports[i].timer, sa1100_timeout, - (unsigned long)&sa1100_ports[i]); + timer_setup(&sa1100_ports[i].timer, sa1100_timeout, 0); } /* diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 31fcc7072a90..d9f399c4e90c 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1058,9 +1058,9 @@ static int scif_rtrg_enabled(struct uart_port *port) (SCFCR_RTRG0 | SCFCR_RTRG1)) != 0; } -static void rx_fifo_timer_fn(unsigned long arg) +static void rx_fifo_timer_fn(struct timer_list *t) { - struct sci_port *s = (struct sci_port *)arg; + struct sci_port *s = from_timer(s, t, rx_fifo_timer); struct uart_port *port = &s->port; dev_dbg(port->dev, "Rx timed out\n"); @@ -1138,8 +1138,7 @@ static ssize_t rx_fifo_timeout_store(struct device *dev, sci->rx_fifo_timeout = r; scif_set_rtrg(port, 1); if (r > 0) - setup_timer(&sci->rx_fifo_timer, rx_fifo_timer_fn, - (unsigned long)sci); + timer_setup(&sci->rx_fifo_timer, rx_fifo_timer_fn, 0); } return count; @@ -1392,9 +1391,9 @@ static void work_fn_tx(struct work_struct *work) dma_async_issue_pending(chan); } -static void rx_timer_fn(unsigned long arg) +static void rx_timer_fn(struct timer_list *t) { - struct sci_port *s = (struct sci_port *)arg; + struct sci_port *s = from_timer(s, t, rx_timer); struct dma_chan *chan = s->chan_rx; struct uart_port *port = &s->port; struct dma_tx_state state; @@ -1572,7 +1571,7 @@ static void sci_request_dma(struct uart_port *port) dma += s->buf_len_rx; } - setup_timer(&s->rx_timer, rx_timer_fn, (unsigned long)s); + timer_setup(&s->rx_timer, rx_timer_fn, 0); if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) sci_submit_rx(s); @@ -2238,8 +2237,7 @@ static void sci_reset(struct uart_port *port) if (s->rx_trigger > 1) { if (s->rx_fifo_timeout) { scif_set_rtrg(port, 1); - setup_timer(&s->rx_fifo_timer, rx_fifo_timer_fn, - (unsigned long)s); + timer_setup(&s->rx_fifo_timer, rx_fifo_timer_fn, 0); } else { if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) diff --git a/drivers/tty/serial/sn_console.c b/drivers/tty/serial/sn_console.c index ed78542c4c37..42b9aded4eb1 100644 --- a/drivers/tty/serial/sn_console.c +++ b/drivers/tty/serial/sn_console.c @@ -612,9 +612,9 @@ static irqreturn_t sn_sal_interrupt(int irq, void *dev_id) * Obviously not used in interrupt mode * */ -static void sn_sal_timer_poll(unsigned long data) +static void sn_sal_timer_poll(struct timer_list *t) { - struct sn_cons_port *port = (struct sn_cons_port *)data; + struct sn_cons_port *port = from_timer(port, t, sc_timer); unsigned long flags; if (!port) @@ -668,7 +668,7 @@ static void __init sn_sal_switch_to_asynch(struct sn_cons_port *port) * timer to poll for input and push data from the console * buffer. */ - setup_timer(&port->sc_timer, sn_sal_timer_poll, (unsigned long)port); + timer_setup(&port->sc_timer, sn_sal_timer_poll, 0); if (IS_RUNNING_ON_SIMULATOR()) port->sc_interrupt_timeout = 6; diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index f2c34d656144..3c4ad71f261d 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c @@ -700,7 +700,7 @@ static void usc_enable_async_clock( struct mgsl_struct *info, u32 DataRate ); static void usc_loopback_frame( struct mgsl_struct *info ); -static void mgsl_tx_timeout(unsigned long context); +static void mgsl_tx_timeout(struct timer_list *t); static void usc_loopmode_cancel_transmit( struct mgsl_struct * info ); @@ -1768,7 +1768,7 @@ static int startup(struct mgsl_struct * info) memset(&info->icount, 0, sizeof(info->icount)); - setup_timer(&info->tx_timer, mgsl_tx_timeout, (unsigned long)info); + timer_setup(&info->tx_timer, mgsl_tx_timeout, 0); /* Allocate and claim adapter resources */ retval = mgsl_claim_resources(info); @@ -7517,9 +7517,9 @@ static void mgsl_trace_block(struct mgsl_struct *info,const char* data, int coun * Arguments: context pointer to device instance data * Return Value: None */ -static void mgsl_tx_timeout(unsigned long context) +static void mgsl_tx_timeout(struct timer_list *t) { - struct mgsl_struct *info = (struct mgsl_struct*)context; + struct mgsl_struct *info = from_timer(info, t, tx_timer); unsigned long flags; if ( debug_level >= DEBUG_LEVEL_INFO ) diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 06a03731bba7..255c49687877 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -493,8 +493,8 @@ static void free_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count) static int alloc_tmp_rbuf(struct slgt_info *info); static void free_tmp_rbuf(struct slgt_info *info); -static void tx_timeout(unsigned long context); -static void rx_timeout(unsigned long context); +static void tx_timeout(struct timer_list *t); +static void rx_timeout(struct timer_list *t); /* * ioctl handlers @@ -3597,8 +3597,8 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev info->adapter_num = adapter_num; info->port_num = port_num; - setup_timer(&info->tx_timer, tx_timeout, (unsigned long)info); - setup_timer(&info->rx_timer, rx_timeout, (unsigned long)info); + timer_setup(&info->tx_timer, tx_timeout, 0); + timer_setup(&info->rx_timer, rx_timeout, 0); /* Copy configuration info to device instance data */ info->pdev = pdev; @@ -5112,9 +5112,9 @@ static int adapter_test(struct slgt_info *info) /* * transmit timeout handler */ -static void tx_timeout(unsigned long context) +static void tx_timeout(struct timer_list *t) { - struct slgt_info *info = (struct slgt_info*)context; + struct slgt_info *info = from_timer(info, t, tx_timer); unsigned long flags; DBGINFO(("%s tx_timeout\n", info->device_name)); @@ -5136,9 +5136,9 @@ static void tx_timeout(unsigned long context) /* * receive buffer polling timer */ -static void rx_timeout(unsigned long context) +static void rx_timeout(struct timer_list *t) { - struct slgt_info *info = (struct slgt_info*)context; + struct slgt_info *info = from_timer(info, t, rx_timer); unsigned long flags; DBGINFO(("%s rx_timeout\n", info->device_name)); diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index d45f234e1914..75f11ce1f0a1 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c @@ -615,8 +615,8 @@ static void free_tmp_rx_buf(SLMP_INFO *info); static void load_pci_memory(SLMP_INFO *info, char* dest, const char* src, unsigned short count); static void trace_block(SLMP_INFO *info, const char* data, int count, int xmit); -static void tx_timeout(unsigned long context); -static void status_timeout(unsigned long context); +static void tx_timeout(struct timer_list *t); +static void status_timeout(struct timer_list *t); static unsigned char read_reg(SLMP_INFO *info, unsigned char addr); static void write_reg(SLMP_INFO *info, unsigned char addr, unsigned char val); @@ -3782,9 +3782,8 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev) info->bus_type = MGSL_BUS_TYPE_PCI; info->irq_flags = IRQF_SHARED; - setup_timer(&info->tx_timer, tx_timeout, (unsigned long)info); - setup_timer(&info->status_timer, status_timeout, - (unsigned long)info); + timer_setup(&info->tx_timer, tx_timeout, 0); + timer_setup(&info->status_timer, status_timeout, 0); /* Store the PCI9050 misc control register value because a flaw * in the PCI9050 prevents LCR registers from being read if @@ -5468,9 +5467,9 @@ static void trace_block(SLMP_INFO *info,const char* data, int count, int xmit) /* called when HDLC frame times out * update stats and do tx completion processing */ -static void tx_timeout(unsigned long context) +static void tx_timeout(struct timer_list *t) { - SLMP_INFO *info = (SLMP_INFO*)context; + SLMP_INFO *info = from_timer(info, t, tx_timer); unsigned long flags; if ( debug_level >= DEBUG_LEVEL_INFO ) @@ -5495,10 +5494,10 @@ static void tx_timeout(unsigned long context) /* called to periodically check the DSR/RI modem signal input status */ -static void status_timeout(unsigned long context) +static void status_timeout(struct timer_list *t) { u16 status = 0; - SLMP_INFO *info = (SLMP_INFO*)context; + SLMP_INFO *info = from_timer(info, t, status_timer); unsigned long flags; unsigned char delta; |