diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-04-28 05:14:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 11:58:30 -0400 |
commit | eb424fd21c0931e998156225f2a0910167c3e16c (patch) | |
tree | 39a49e87d0dfaa75b0f02b6f64c49beba9f079b6 /drivers/serial | |
parent | e991a2bd4fa0b2f475b67dfe8f33e8ecbdcbb40b (diff) |
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')
-rw-r--r-- | drivers/serial/serial_core.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index a9ca03ead3e5..977ce820ce30 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -329,13 +329,15 @@ EXPORT_SYMBOL(uart_update_timeout); | |||
329 | * If it's still invalid, we try 9600 baud. | 329 | * If it's still invalid, we try 9600 baud. |
330 | * | 330 | * |
331 | * Update the @termios structure to reflect the baud rate | 331 | * Update the @termios structure to reflect the baud rate |
332 | * we're actually going to be using. | 332 | * we're actually going to be using. Don't do this for the case |
333 | * where B0 is requested ("hang up"). | ||
333 | */ | 334 | */ |
334 | unsigned int | 335 | unsigned int |
335 | uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, | 336 | uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, |
336 | struct ktermios *old, unsigned int min, unsigned int max) | 337 | struct ktermios *old, unsigned int min, unsigned int max) |
337 | { | 338 | { |
338 | unsigned int try, baud, altbaud = 38400; | 339 | unsigned int try, baud, altbaud = 38400; |
340 | int hung_up = 0; | ||
339 | upf_t flags = port->flags & UPF_SPD_MASK; | 341 | upf_t flags = port->flags & UPF_SPD_MASK; |
340 | 342 | ||
341 | if (flags == UPF_SPD_HI) | 343 | if (flags == UPF_SPD_HI) |
@@ -360,8 +362,10 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, | |||
360 | /* | 362 | /* |
361 | * Special case: B0 rate. | 363 | * Special case: B0 rate. |
362 | */ | 364 | */ |
363 | if (baud == 0) | 365 | if (baud == 0) { |
366 | hung_up = 1; | ||
364 | baud = 9600; | 367 | baud = 9600; |
368 | } | ||
365 | 369 | ||
366 | if (baud >= min && baud <= max) | 370 | if (baud >= min && baud <= max) |
367 | return baud; | 371 | return baud; |
@@ -373,7 +377,9 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, | |||
373 | termios->c_cflag &= ~CBAUD; | 377 | termios->c_cflag &= ~CBAUD; |
374 | if (old) { | 378 | if (old) { |
375 | baud = tty_termios_baud_rate(old); | 379 | baud = tty_termios_baud_rate(old); |
376 | tty_termios_encode_baud_rate(termios, baud, baud); | 380 | if (!hung_up) |
381 | tty_termios_encode_baud_rate(termios, | ||
382 | baud, baud); | ||
377 | old = NULL; | 383 | old = NULL; |
378 | continue; | 384 | continue; |
379 | } | 385 | } |
@@ -382,7 +388,8 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, | |||
382 | * As a last resort, if the quotient is zero, | 388 | * As a last resort, if the quotient is zero, |
383 | * default to 9600 bps | 389 | * default to 9600 bps |
384 | */ | 390 | */ |
385 | tty_termios_encode_baud_rate(termios, 9600, 9600); | 391 | if (!hung_up) |
392 | tty_termios_encode_baud_rate(termios, 9600, 9600); | ||
386 | } | 393 | } |
387 | 394 | ||
388 | return 0; | 395 | return 0; |