aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaavard Skinnemoen <hskinnemoen@atmel.com>2006-10-04 10:02:11 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-04 13:25:06 -0400
commit4d5e392c33820dc8861423bb1b8dae205ea0ad3d (patch)
treef76a7905ca8a7d8afc25156a2b4608743ffcd128
parentc194588dba968510b5aa7a1818bd2c8b36a416f7 (diff)
[PATCH] atmel_serial: Fix roundoff error in atmel_console_get_options
The atmel_console_get_options() function initializes the baud, parity and bits settings from the actual hardware setup, in case it has been initialized by a e.g. boot loader. The baud rate, however, is not necessarily exactly equal to one of the standard baud rates (115200, etc.) This means that the baud rate calculated by this function may be slightly higher or slightly lower than one of the standard baud rates. If the baud rate is slightly lower than the target, this causes problems when uart_set_option() tries to match the detected baud rate against the standard baud rate, as it will always select a baud rate that is lower or equal to the target rate. For example if the detected baud rate is slightly lower than 115200, usart_set_options() will select 57600. This patch fixes the problem by subtracting 1 from the value in BRGR when calculating the baud rate. The detected baud rate will thus always be higher than the nearest standard baud rate, and uart_set_options() will end up doing the right thing. Tested on ATSTK1000 and AT91RM9200-EK boards. Both are broken without this patch. Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Acked-by: Andrew Victor <andrew@sanpeople.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/serial/atmel_serial.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index 61db2166fbb5..955c46da5800 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -793,8 +793,14 @@ static void __init atmel_console_get_options(struct uart_port *port, int *baud,
793 else if (mr == ATMEL_US_PAR_ODD) 793 else if (mr == ATMEL_US_PAR_ODD)
794 *parity = 'o'; 794 *parity = 'o';
795 795
796 /*
797 * The serial core only rounds down when matching this to a
798 * supported baud rate. Make sure we don't end up slightly
799 * lower than one of those, as it would make us fall through
800 * to a much lower baud rate than we really want.
801 */
796 quot = UART_GET_BRGR(port); 802 quot = UART_GET_BRGR(port);
797 *baud = port->uartclk / (16 * (quot)); 803 *baud = port->uartclk / (16 * (quot - 1));
798} 804}
799 805
800static int __init atmel_console_setup(struct console *co, char *options) 806static int __init atmel_console_setup(struct console *co, char *options)