linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: 8250: Convert timers to use timer_setup()
@ 2017-10-24  9:59 Kees Cook
  2017-10-26 16:22 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2017-10-24  9:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Andy Shevchenko, Vignesh R, Ed Blake,
	Matthias Brugger, Sean Young, linux-serial, linux-kernel

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Vignesh R <vigneshr@ti.com>
Cc: Ed Blake <ed.blake@imgtec.com>
Cc: Matthias Brugger <mbrugger@suse.com>
Cc: Sean Young <sean@mess.org>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/tty/serial/8250/8250_core.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 00d4b114f1bf..ccfc42ca846d 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -262,17 +262,17 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up)
  * barely passable results for a 16550A.  (Although at the expense
  * of much CPU overhead).
  */
-static void serial8250_timeout(unsigned long data)
+static void serial8250_timeout(struct timer_list *t)
 {
-	struct uart_8250_port *up = (struct uart_8250_port *)data;
+	struct uart_8250_port *up = from_timer(up, t, timer);
 
 	up->port.handle_irq(&up->port);
 	mod_timer(&up->timer, jiffies + uart_poll_timeout(&up->port));
 }
 
-static void serial8250_backup_timeout(unsigned long data)
+static void serial8250_backup_timeout(struct timer_list *t)
 {
-	struct uart_8250_port *up = (struct uart_8250_port *)data;
+	struct uart_8250_port *up = from_timer(up, t, timer);
 	unsigned int iir, ier = 0, lsr;
 	unsigned long flags;
 
@@ -329,8 +329,7 @@ static int univ8250_setup_irq(struct uart_8250_port *up)
 	if (up->bugs & UART_BUG_THRE) {
 		pr_debug("ttyS%d - using backup timer\n", serial_index(port));
 
-		up->timer.function = serial8250_backup_timeout;
-		up->timer.data = (unsigned long)up;
+		up->timer.function = (TIMER_FUNC_TYPE)serial8250_backup_timeout;
 		mod_timer(&up->timer, jiffies +
 			  uart_poll_timeout(port) + HZ / 5);
 	}
@@ -341,7 +340,6 @@ static int univ8250_setup_irq(struct uart_8250_port *up)
 	 * driver used to do this with IRQ0.
 	 */
 	if (!port->irq) {
-		up->timer.data = (unsigned long)up;
 		mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
 	} else
 		retval = serial_link_irq_chain(up);
@@ -354,7 +352,7 @@ static void univ8250_release_irq(struct uart_8250_port *up)
 	struct uart_port *port = &up->port;
 
 	del_timer_sync(&up->timer);
-	up->timer.function = serial8250_timeout;
+	up->timer.function = (TIMER_FUNC_TYPE)serial8250_timeout;
 	if (port->irq)
 		serial_unlink_irq_chain(up);
 }
@@ -525,7 +523,7 @@ static void __init serial8250_isa_init_ports(void)
 			base_ops = port->ops;
 		port->ops = &univ8250_port_ops;
 
-		setup_timer(&up->timer, serial8250_timeout, 0UL);
+		timer_setup(&up->timer, serial8250_timeout, 0);
 
 		up->ops = &univ8250_driver_ops;
 
-- 
2.7.4


-- 
Kees Cook
Pixel Security

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: 8250: Convert timers to use timer_setup()
  2017-10-24  9:59 [PATCH] serial: 8250: Convert timers to use timer_setup() Kees Cook
@ 2017-10-26 16:22 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2017-10-26 16:22 UTC (permalink / raw)
  To: Kees Cook, Greg Kroah-Hartman
  Cc: Jiri Slaby, Vignesh R, Ed Blake, Matthias Brugger, Sean Young,
	linux-serial, linux-kernel

On Tue, 2017-10-24 at 02:59 -0700, Kees Cook wrote:
> In preparation for unconditionally passing the struct timer_list
> pointer to
> all timer callbacks, switch to using the new timer_setup() and
> from_timer()
> to pass the timer pointer explicitly.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Jiri Slaby <jslaby@suse.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Vignesh R <vigneshr@ti.com>
> Cc: Ed Blake <ed.blake@imgtec.com>
> Cc: Matthias Brugger <mbrugger@suse.com>
> Cc: Sean Young <sean@mess.org>
> Cc: linux-serial@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  drivers/tty/serial/8250/8250_core.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_core.c
> b/drivers/tty/serial/8250/8250_core.c
> index 00d4b114f1bf..ccfc42ca846d 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -262,17 +262,17 @@ static void serial_unlink_irq_chain(struct
> uart_8250_port *up)
>   * barely passable results for a 16550A.  (Although at the expense
>   * of much CPU overhead).
>   */
> -static void serial8250_timeout(unsigned long data)
> +static void serial8250_timeout(struct timer_list *t)
>  {
> -	struct uart_8250_port *up = (struct uart_8250_port *)data;
> +	struct uart_8250_port *up = from_timer(up, t, timer);
>  
>  	up->port.handle_irq(&up->port);
>  	mod_timer(&up->timer, jiffies + uart_poll_timeout(&up-
> >port));
>  }
>  
> -static void serial8250_backup_timeout(unsigned long data)
> +static void serial8250_backup_timeout(struct timer_list *t)
>  {
> -	struct uart_8250_port *up = (struct uart_8250_port *)data;
> +	struct uart_8250_port *up = from_timer(up, t, timer);
>  	unsigned int iir, ier = 0, lsr;
>  	unsigned long flags;
>  
> @@ -329,8 +329,7 @@ static int univ8250_setup_irq(struct
> uart_8250_port *up)
>  	if (up->bugs & UART_BUG_THRE) {
>  		pr_debug("ttyS%d - using backup timer\n",
> serial_index(port));
>  
> -		up->timer.function = serial8250_backup_timeout;
> -		up->timer.data = (unsigned long)up;
> +		up->timer.function =
> (TIMER_FUNC_TYPE)serial8250_backup_timeout;
>  		mod_timer(&up->timer, jiffies +
>  			  uart_poll_timeout(port) + HZ / 5);
>  	}
> @@ -341,7 +340,6 @@ static int univ8250_setup_irq(struct
> uart_8250_port *up)
>  	 * driver used to do this with IRQ0.
>  	 */
>  	if (!port->irq) {
> -		up->timer.data = (unsigned long)up;
>  		mod_timer(&up->timer, jiffies +
> uart_poll_timeout(port));
>  	} else
>  		retval = serial_link_irq_chain(up);
> @@ -354,7 +352,7 @@ static void univ8250_release_irq(struct
> uart_8250_port *up)
>  	struct uart_port *port = &up->port;
>  
>  	del_timer_sync(&up->timer);
> -	up->timer.function = serial8250_timeout;
> +	up->timer.function = (TIMER_FUNC_TYPE)serial8250_timeout;
>  	if (port->irq)
>  		serial_unlink_irq_chain(up);
>  }
> @@ -525,7 +523,7 @@ static void __init serial8250_isa_init_ports(void)
>  			base_ops = port->ops;
>  		port->ops = &univ8250_port_ops;
>  
> -		setup_timer(&up->timer, serial8250_timeout, 0UL);
> +		timer_setup(&up->timer, serial8250_timeout, 0);
>  
>  		up->ops = &univ8250_driver_ops;
>  
> -- 
> 2.7.4
> 
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-26 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-24  9:59 [PATCH] serial: 8250: Convert timers to use timer_setup() Kees Cook
2017-10-26 16:22 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).