summaryrefslogtreecommitdiffstats
path: root/drivers/serial/serial_core.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-04-28 02:14:07 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 08:58:30 -0700
commiteb424fd21c0931e998156225f2a0910167c3e16c (patch)
tree39a49e87d0dfaa75b0f02b6f64c49beba9f079b6 /drivers/serial/serial_core.c
parente991a2bd4fa0b2f475b67dfe8f33e8ecbdcbb40b (diff)
downloadop-kernel-dev-eb424fd21c0931e998156225f2a0910167c3e16c.zip
op-kernel-dev-eb424fd21c0931e998156225f2a0910167c3e16c.tar.gz
uart_get_baud_rate: stop mangling termios
Russell King noticed this one: We have to avoid replacing B0 when we pick a baud rate for a "hung up" port. Ugly but the proper fix is in the tty layer and means changing the tty<->serial interfaces so we will defer that for now. [akpm@linux-foundation.org: fix uninitialised var] Signed-off-by: Alan Cox <alan@redhat.com> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/serial/serial_core.c')
-rw-r--r--drivers/serial/serial_core.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index a9ca03e..977ce82 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -329,13 +329,15 @@ EXPORT_SYMBOL(uart_update_timeout);
* If it's still invalid, we try 9600 baud.
*
* Update the @termios structure to reflect the baud rate
- * we're actually going to be using.
+ * we're actually going to be using. Don't do this for the case
+ * where B0 is requested ("hang up").
*/
unsigned int
uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
struct ktermios *old, unsigned int min, unsigned int max)
{
unsigned int try, baud, altbaud = 38400;
+ int hung_up = 0;
upf_t flags = port->flags & UPF_SPD_MASK;
if (flags == UPF_SPD_HI)
@@ -360,8 +362,10 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
/*
* Special case: B0 rate.
*/
- if (baud == 0)
+ if (baud == 0) {
+ hung_up = 1;
baud = 9600;
+ }
if (baud >= min && baud <= max)
return baud;
@@ -373,7 +377,9 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
termios->c_cflag &= ~CBAUD;
if (old) {
baud = tty_termios_baud_rate(old);
- tty_termios_encode_baud_rate(termios, baud, baud);
+ if (!hung_up)
+ tty_termios_encode_baud_rate(termios,
+ baud, baud);
old = NULL;
continue;
}
@@ -382,7 +388,8 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
* As a last resort, if the quotient is zero,
* default to 9600 bps
*/
- tty_termios_encode_baud_rate(termios, 9600, 9600);
+ if (!hung_up)
+ tty_termios_encode_baud_rate(termios, 9600, 9600);
}
return 0;
OpenPOWER on IntegriCloud