summaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorLukas Wunner <lukas@wunner.de>2022-11-09 08:04:34 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-11-09 13:03:55 +0100
commitd85bf5105853d57ed27c6c21ac35424cc44a0fbb (patch)
tree56ec6f0b1a2178095072f246b7fca6c92061978c /drivers/tty
parent6a3ff858915fa8ca36c7eb02c87c9181ae2fc333 (diff)
downloadlinux-d85bf5105853d57ed27c6c21ac35424cc44a0fbb.tar.gz
linux-d85bf5105853d57ed27c6c21ac35424cc44a0fbb.tar.bz2
linux-d85bf5105853d57ed27c6c21ac35424cc44a0fbb.zip
serial: 8250: 8250_omap: Fix calculation of RS485 delays
Commit 801954d1210a ("serial: 8250: 8250_omap: Support native RS485") calculates RS485 delays from the baudrate. The baudrate is generated with either a 16x or 13x divisor. The divisor is set in the Mode Definition Register 1 (MDR1). The commit erroneously assumes that the register stores the divisor as a bitmask and uses a logical AND to differentiate between 16x and 13x divisors. However the divisor is really stored as a 3-bit mode (see lines 363ff in include/uapi/linux/serial_reg.h). The logical AND operation is performed with UART_OMAP_MDR1_16X_MODE, which is defined as 0x0 and hence yields false. So the commit always assumes a 13x divisor. Fix by using an equal comparison. This works because we never set any of the other 5 bits in the register. (They pertain to IrDA mode, which is not supported by the driver). Fixes: 801954d1210a ("serial: 8250: 8250_omap: Support native RS485") Link: https://lore.kernel.org/linux-serial/202211070440.8hWunFUN-lkp@intel.com/ Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/7d5b04da13d89b8708b9543a0b125f2b6062a77b.1667977259.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/8250/8250_omap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 1c8a48fdc8f2..7bb9da7558a1 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -822,7 +822,7 @@ static int omap8250_rs485_config(struct uart_port *port,
* of the AM65 TRM: https://www.ti.com/lit/ug/spruid7e/spruid7e.pdf
*/
if (priv->quot) {
- if (priv->mdr1 & UART_OMAP_MDR1_16X_MODE)
+ if (priv->mdr1 == UART_OMAP_MDR1_16X_MODE)
baud = port->uartclk / (16 * priv->quot);
else
baud = port->uartclk / (13 * priv->quot);