Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a768264 authored by Eddie Huang's avatar Eddie Huang Committed by Greg Kroah-Hartman
Browse files

tty: serial: Fix mediatek UART driver setting baudrate issue



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: default avatarEddie Huang <eddie.huang@mediatek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7645c2f4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
	}

	/*