提交 4c0fbf07 编写于 作者: P Pali Rohár 提交者: Zheng Zengkai

serial: mvebu-uart: do not allow changing baudrate when uartclk is not available

stable inclusion
from stable-5.10.50
commit 9ad82f0412c04f7cf8a8522a5dca633a0c40135a
bugzilla: 174522 https://gitee.com/openeuler/kernel/issues/I4DNFY

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9ad82f0412c04f7cf8a8522a5dca633a0c40135a

--------------------------------

[ Upstream commit ecd6b010 ]

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: NPali Rohár <pali@kernel.org>
Fixes: 68a0db1d ("serial: mvebu-uart: add function to change baudrate")
Link: https://lore.kernel.org/r/20210624224909.6350-3-pali@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 a9e8908d
...@@ -445,12 +445,11 @@ static void mvebu_uart_shutdown(struct uart_port *port) ...@@ -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) 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; unsigned int d_divisor, m_divisor;
u32 brdv, osamp; u32 brdv, osamp;
if (IS_ERR(mvuart->clk)) if (!port->uartclk)
return -PTR_ERR(mvuart->clk); return -EOPNOTSUPP;
/* /*
* The baudrate is derived from the UART clock thanks to two divisors: * The baudrate is derived from the UART clock thanks to two divisors:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册