From 7d49ed0ae2fe90004d7ebe848dc97ecd81a5ccb0 Mon Sep 17 00:00:00 2001 From: aystarik Date: Fri, 9 Sep 2016 18:00:07 +0300 Subject: [PATCH] Fix fractional calculation --- drivers/tty/serial/atmel_serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 837882249d9898..f15f882bb6684b 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2176,9 +2176,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, */ if (atmel_port->has_frac_baudrate && (mode & ATMEL_US_USMODE) == ATMEL_US_USMODE_NORMAL) { - div = DIV_ROUND_CLOSEST(port->uartclk, baud); - cd = div / 16; - fp = DIV_ROUND_CLOSEST(div % 16, 2); + div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2); + cd = div >> 3; + fp = div & 7; } else { cd = uart_get_divisor(port, baud); }