[PATCH 34/49] serial: Factor out uart_poll_timeout() from 8250 driver

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg Kroah-Hartman
Date: Friday, October 22, 2010 - 11:21 am

From: Anton Vorontsov <cbouatmailru@gmail.com>

Soon we will use that handy function in the altera_uart driver.

Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/serial/8250.c       |   14 ++++----------
 include/linux/serial_core.h |    8 ++++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 31b8cca..b586406 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1722,12 +1722,6 @@ static void serial_unlink_irq_chain(struct uart_8250_port *up)
 	mutex_unlock(&hash_mutex);
 }
 
-/* Base timer interval for polling */
-static inline int poll_timeout(int timeout)
-{
-	return timeout > 6 ? (timeout / 2 - 2) : 1;
-}
-
 /*
  * This function is used to handle ports that do not have an
  * interrupt.  This doesn't work very well for 16450's, but gives
@@ -1742,7 +1736,7 @@ static void serial8250_timeout(unsigned long data)
 	iir = serial_in(up, UART_IIR);
 	if (!(iir & UART_IIR_NO_INT))
 		serial8250_handle_port(up);
-	mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout));
+	mod_timer(&up->timer, jiffies + uart_poll_timeout(&up->port));
 }
 
 static void serial8250_backup_timeout(unsigned long data)
@@ -1787,7 +1781,7 @@ static void serial8250_backup_timeout(unsigned long data)
 
 	/* Standard timer interval plus 0.2s to keep the port running */
 	mod_timer(&up->timer,
-		jiffies + poll_timeout(up->port.timeout) + HZ / 5);
+		jiffies + uart_poll_timeout(&up->port) + HZ / 5);
 }
 
 static unsigned int serial8250_tx_empty(struct uart_port *port)
@@ -2071,7 +2065,7 @@ static int serial8250_startup(struct uart_port *port)
 		up->timer.function = serial8250_backup_timeout;
 		up->timer.data = (unsigned long)up;
 		mod_timer(&up->timer, jiffies +
-			  poll_timeout(up->port.timeout) + HZ / 5);
+			uart_poll_timeout(port) + HZ / 5);
 	}
 
 	/*
@@ -2081,7 +2075,7 @@ static int serial8250_startup(struct uart_port *port)
 	 */
 	if (!is_real_interrupt(up->port.irq)) {
 		up->timer.data = (unsigned long)up;
-		mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout));
+		mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
 	} else {
 		retval = serial_link_irq_chain(up);
 		if (retval)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 563e234..ac48082 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -411,6 +411,14 @@ unsigned int uart_get_baud_rate(struct uart_port *port, struct ktermios *termios
 				unsigned int max);
 unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud);
 
+/* Base timer interval for polling */
+static inline int uart_poll_timeout(struct uart_port *port)
+{
+	int timeout = port->timeout;
+
+	return timeout > 6 ? (timeout / 2 - 2) : 1;
+}
+
 /*
  * Console helpers.
  */
-- 
1.7.2

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PATCH] TTY/Serial merge for .37-rc1, Greg KH, (Fri Oct 22, 10:51 am)
[PATCH 01/49] tty: add tty_struct-&gt;dev pointer to correspo ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 02/49] serport: place serport serio device correctl ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 03/49] serial: mfd: snprintf() returns largish values, Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 04/49] serial: Add CONSOLE_POLL support for uartlite, Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 05/49] tty: Remove __GFP_NOFAIL from tty_add_file(), Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 06/49] ioctl: Use asm-generic/ioctls.h on arm (enab ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 07/49] ioctl: Use asm-generic/ioctls.h on avr32 (en ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 08/49] ioctl: Use asm-generic/ioctls.h on cris (ena ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 09/49] ioctl: Use asm-generic/ioctls.h on frv (enab ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 10/49] ioctl: Use asm-generic/ioctls.h on h8300 (en ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 11/49] ioctl: Use asm-generic/ioctls.h on ia64 (ena ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 12/49] ioctl: Use asm-generic/ioctls.h on m32r (ena ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 13/49] ioctl: Use asm-generic/ioctls.h on m68k (ena ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 14/49] ioctl: Use asm-generic/ioctls.h on mn10300 ( ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 15/49] ioctl: Use asm-generic/ioctls.h on s390 (ena ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 16/49] serial-core: skip call set_termios/console_s ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 17/49] serial-core: restore termios settings when r ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 18/49] add ttyprintk driver, Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 19/49] Char: mxser, call pci_disable_device from pr ..., Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 20/49] tty_io: check return code of tty_register_device, Greg Kroah-Hartman, (Fri Oct 22, 11:20 am)
[PATCH 21/49] serial: mrst_max3110: some code cleanup, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 22/49] serial: mrst_max3110: Make the IRQ option ru ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 23/49] serial: max3107: Fix memory leaks when retur ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 24/49] tty: Make tiocgicount a handler, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 25/49] tty: Convert the USB drivers to the new icou ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 26/49] tty: icount changeover for other main devices, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 27/49] tty: Fix warning left over from TIOCGICOUNT ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 28/49] tty: Add a new file /proc/tty/consoles, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 29/49] vcs: add poll/fasync support, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 30/49] vcs: invoke the vt update callback when /dev ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 31/49] tty: MAINTAINERS: add drivers/serial/jsm/ as ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 32/49] serial: 8250: Don't delay after transmitter ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 33/49] serial: mark the 8250 driver as maintained, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 34/49] serial: Factor out uart_poll_timeout() from ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 35/49] altera_uart: Add support for polling mode (I ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 36/49] altera_uart: Add support for getting mapbase ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 37/49] altera_uart: Add support for different addre ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 38/49] altera_uart: Make it possible to use Altera ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 39/49] altera_uart: Fixup type usage of port flags, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 40/49] altera_uart: Fix missing prototype for regis ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 41/49] altera_uart: Don't use plain integer as NULL ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 42/49] 8250: allow platforms to override PM hook., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 43/49] Alchemy: Add UART PM methods., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 44/49] jsm: Remove the uart port on errors, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 45/49] serial: mfd: add more baud rates support, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 46/49] serial/imx: check that the buffer is non-emp ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 47/49] serial: abstraction for 8250 legacy ports, Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
[PATCH 48/49] serial: bfin_sport_uart: speed up sport RX s ..., Greg Kroah-Hartman, (Fri Oct 22, 11:21 am)
Re: [PATCH 28/49] tty: Add a new file /proc/tty/consoles, Christoph Hellwig, (Sat Oct 23, 4:46 am)
Re: [PATCH 28/49] tty: Add a new file /proc/tty/consoles, Dr. Werner Fink, (Mon Oct 25, 12:51 am)
Re: [PATCH 28/49] tty: Add a new file /proc/tty/consoles, Dr. Werner Fink, (Wed Oct 27, 2:27 am)
Re: [PATCH 28/49] tty: Add a new file /proc/tty/consoles, Dr. Werner Fink, (Wed Oct 27, 4:31 am)
Re: [PATCH 29/49] vcs: add poll/fasync support, Kay Sievers, (Tue Nov 9, 5:12 pm)
Re: [PATCH 29/49] vcs: add poll/fasync support, Nicolas Pitre, (Tue Nov 9, 6:26 pm)
Re: [PATCH 29/49] vcs: add poll/fasync support, Kay Sievers, (Tue Nov 9, 6:42 pm)
Re: [PATCH 29/49] vcs: add poll/fasync support, Nicolas Pitre, (Tue Nov 9, 11:33 pm)
Re: [PATCH 29/49] vcs: add poll/fasync support, Kay Sievers, (Wed Nov 10, 2:35 am)