]> git.itanic.dy.fi Git - linux-stable/commit
serial: 8250: Fix reporting real baudrate value in c_ospeed field
authorPali Rohár <pali@kernel.org>
Mon, 27 Sep 2021 09:37:04 +0000 (11:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Sep 2022 12:16:55 +0000 (14:16 +0200)
commit59819f0aafd089cfbf8c087895f8c541af67392e
tree2a943763f20a93b7b3f523035760ab25f712ef64
parent9230af9188a2cc8872fb98ea50907f3440a1786a
serial: 8250: Fix reporting real baudrate value in c_ospeed field

[ Upstream commit 32262e2e429cdb31f9e957e997d53458762931b7 ]

In most cases it is not possible to set exact baudrate value to hardware.

So fix reporting real baudrate value which was set to hardware via c_ospeed
termios field. It can be retrieved by ioctl(TCGETS2) from userspace.

Real baudrate value is calculated from chosen hardware divisor and base
clock. It is implemented in a new function serial8250_compute_baud_rate()
which is inverse of serial8250_get_divisor() function.

With this change is fixed also UART timeout value (it is updated via
uart_update_timeout() function), which is calculated from the now fixed
baudrate value too.

Cc: stable@vger.kernel.org
Signed-off-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210927093704.19768-1-pali@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/8250/8250_port.c