Skip to content

Commit

Permalink
serial: mvebu-uart: fix calculation of clock divisor
Browse files Browse the repository at this point in the history
commit 9078204 upstream.

The clock divisor should be rounded to the closest value.

Signed-off-by: Pali Rohár <pali@kernel.org>
Fixes: 68a0db1 ("serial: mvebu-uart: add function to change baudrate")
Cc: stable@vger.kernel.org # 0e4cf69 ("serial: mvebu-uart: clarify the baud rate derivation")
Link: https://lore.kernel.org/r/20210624224909.6350-2-pali@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
pali authored and gregkh committed Jul 14, 2021
1 parent de8eea1 commit 10f409e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/tty/serial/mvebu-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)
* makes use of D to configure the desired baudrate.
*/
m_divisor = OSAMP_DEFAULT_DIVISOR;
d_divisor = DIV_ROUND_UP(port->uartclk, baud * m_divisor);
d_divisor = DIV_ROUND_CLOSEST(port->uartclk, baud * m_divisor);

brdv = readl(port->membase + UART_BRDV);
brdv &= ~BRDV_BAUD_MASK;
Expand Down

0 comments on commit 10f409e

Please sign in to comment.