Skip to content

Commit

Permalink
tty: serial: Fix mediatek UART driver setting baudrate issue
Browse files Browse the repository at this point in the history
In mtk8250_set_termios function, calculating quot value can not be zero,
otherwise, using DIV_ROUND_CLOSEST(port->uartclk, quot * baud) will fail due to
divisor is zero.

Signed-off-by: Eddie Huang <eddie.huang@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Eddie Huang authored and Greg Kroah-Hartman committed Nov 6, 2014
1 parent 7645c2f commit 2a76826
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/tty/serial/8250/8250_mtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
/* Set to next lower baudrate supported */
if ((baud == 500000) || (baud == 576000))
baud = 460800;
quot = DIV_ROUND_CLOSEST(port->uartclk, 4 * baud);
quot = DIV_ROUND_UP(port->uartclk, 4 * baud);
} else {
serial_port_out(port, UART_MTK_HIGHS, 0x3);

/* Set to highest baudrate supported */
if (baud >= 1152000)
baud = 921600;
quot = DIV_ROUND_CLOSEST(port->uartclk, 256 * baud);
quot = DIV_ROUND_UP(port->uartclk, 256 * baud);
}

/*
Expand Down

0 comments on commit 2a76826

Please sign in to comment.