Skip to content

Commit

Permalink
serial: mvebu-uart: do not allow changing baudrate when uartclk is no…
Browse files Browse the repository at this point in the history
…t available

[ Upstream commit ecd6b01 ]

Testing mvuart->clk for non-error is not enough as mvuart->clk may contain
valid clk pointer but when clk_prepare_enable(mvuart->clk) failed then
port->uartclk is zero.

When mvuart->clk is not available then port->uartclk is zero too.

Parent clock rate port->uartclk is needed to calculate UART clock divisor
and without it is not possible to change baudrate.

So fix test condition when it is possible to change baudrate.

Signed-off-by: Pali Rohár <pali@kernel.org>
Fixes: 68a0db1 ("serial: mvebu-uart: add function to change baudrate")
Link: https://lore.kernel.org/r/20210624224909.6350-3-pali@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
pali authored and gregkh committed Jul 14, 2021
1 parent ce2d17c commit 59146c5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/tty/serial/mvebu-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,11 @@ static void mvebu_uart_shutdown(struct uart_port *port)

static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)
{
struct mvebu_uart *mvuart = to_mvuart(port);
unsigned int d_divisor, m_divisor;
u32 brdv, osamp;

if (IS_ERR(mvuart->clk))
return -PTR_ERR(mvuart->clk);
if (!port->uartclk)
return -EOPNOTSUPP;

/*
* The baudrate is derived from the UART clock thanks to two divisors:
Expand Down

0 comments on commit 59146c5

Please sign in to comment.