diff mbox series

[1/5] serial: sprd: Modify the baud rate calculation formula

Message ID a816deaf850b3620457ab3d071345ec572c63477.1550560916.git.baolin.wang@linaro.org
State Superseded
Headers show
Series Add new features for the Spreadtrum serial controller | expand

Commit Message

(Exiting) Baolin Wang Feb. 19, 2019, 7:31 a.m. UTC
From: Lanqing Liu <lanqing.liu@unisoc.com>


When the source clock is not divisible by the expected baud rate and
the remainder is not less than half of the expected baud rate, the old
formular will round up the frequency division coefficient. This will
make the actual baud rate less than the expected value and can not meet
the external transmission requirements.

Thus this patch modifies the baud rate calculation formula to support
the serial controller output the maximum baud rate.

Signed-off-by: Lanqing Liu <lanqing.liu@unisoc.com>

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>

---
 drivers/tty/serial/sprd_serial.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
1.7.9.5
diff mbox series

Patch

diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 4287ca3..1891a45 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -371,7 +371,7 @@  static void sprd_set_termios(struct uart_port *port,
 	/* ask the core to calculate the divisor for us */
 	baud = uart_get_baud_rate(port, termios, old, 0, SPRD_BAUD_IO_LIMIT);
 
-	quot = (unsigned int)((port->uartclk + baud / 2) / baud);
+	quot = port->uartclk / baud;
 
 	/* set data length */
 	switch (termios->c_cflag & CSIZE) {