summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@flint.arm.linux.org.uk>2002-12-01 15:55:57 +0000
committerRussell King <rmk@flint.arm.linux.org.uk>2002-12-01 15:55:57 +0000
commit9f22efdf0bb455ff1e2b683c740d81baa7668444 (patch)
treeb437780d06a91a48594905505b999ec7b8ac6fbb
parent512c56371986912bfaf9b20ffc50a5f47bb93791 (diff)
[SERIAL] Move the FIFO timeout calculations into uart_update_timeout()
-rw-r--r--drivers/serial/core.c83
1 files changed, 51 insertions, 32 deletions
diff --git a/drivers/serial/core.c b/drivers/serial/core.c
index 5c0bd92ab923..af35d6150054 100644
--- a/drivers/serial/core.c
+++ b/drivers/serial/core.c
@@ -261,6 +261,56 @@ static void uart_shutdown(struct uart_info *info)
}
/**
+ * uart_update_timeout - update per-port FIFO timeout.
+ * @port: uart_port structure describing the port.
+ * @cflag: termios cflag value
+ * @quot: uart clock divisor quotient
+ *
+ * Set the port FIFO timeout value. The @cflag value should
+ * reflect the actual hardware settings.
+ */
+void
+uart_update_timeout(struct uart_port *port, unsigned int cflag,
+ unsigned int quot)
+{
+ unsigned int bits;
+
+ /* byte size and parity */
+ switch (cflag & CSIZE) {
+ case CS5:
+ bits = 7;
+ break;
+ case CS6:
+ bits = 8;
+ break;
+ case CS7:
+ bits = 9;
+ break;
+ default:
+ bits = 10;
+ break; // CS8
+ }
+
+ if (cflag & CSTOPB)
+ bits++;
+ if (cflag & PARENB)
+ bits++;
+
+ /*
+ * The total number of bits to be transmitted in the fifo.
+ */
+ bits = bits * port->fifosize;
+
+ /*
+ * Figure the timeout to send the above number of bits.
+ * Add .02 seconds of slop
+ */
+ port->timeout = (HZ * bits) / (port->uartclk / (16 * quot)) + HZ/50;
+}
+
+EXPORT_SYMBOL(uart_update_timeout);
+
+/**
* uart_get_baud_rate - return baud rate for a particular port
* @port: uart_port structure describing the port in question.
* @tty: the tty structure corresponding to this port
@@ -386,39 +436,8 @@ uart_change_speed(struct uart_info *info, struct termios *old_termios)
*/
cflag = info->tty->termios->c_cflag;
- /* byte size and parity */
- switch (cflag & CSIZE) {
- case CS5:
- bits = 7;
- break;
- case CS6:
- bits = 8;
- break;
- case CS7:
- bits = 9;
- break;
- default:
- bits = 10;
- break; // CS8
- }
-
- if (cflag & CSTOPB)
- bits++;
- if (cflag & PARENB)
- bits++;
-
quot = uart_get_divisor(port, tty, old_termios);
-
- /*
- * The total number of bits to be transmitted in the fifo.
- */
- bits = bits * port->fifosize;
-
- /*
- * Figure the timeout to send the above number of bits.
- * Add .02 seconds of slop
- */
- port->timeout = (HZ * bits) / (port->uartclk / (16 * quot)) + HZ/50;
+ uart_update_timeout(port, cflag, quot);
if (cflag & CRTSCTS)
info->flags |= UIF_CTS_FLOW;