serial: Sanitize rs485_struct
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 6 Jun 2022 10:04:19 +0000 (13:04 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jun 2022 11:49:57 +0000 (13:49 +0200)
commitbe2e2cb1d28195792539ac2539f8c40c39d3dd4c
tree4249ae287f350aa0713c4db269bc50dbdff87da9
parentaeae8f222fdd34bdddc1050dc073e56b2242c9b5
serial: Sanitize rs485_struct

Sanitize serial_rs485 struct before calling into rs485_setup. The
drivers provide supported_rs485 to help sanitization of the fields.

If neither of SER_RS485_RTS_ON_SEND or SER_RS485_RTS_AFTER_SEND
supported, don't pretend they can be set to sane settings but clear
them both instead. If only one of them is supported it may look
tempting to use the one driver supports to set the other, however, the
userspace does not have that information readily available so it
wouldn't be helpful.

While adjusting the documentation, remove also the claim that
TIOCGRS485 would call driver specific code. In reality, it does nothing
else than copies the stored serial_rs485 structure from uart_port to
userspace.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220606100433.13793-23-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/driver-api/serial/serial-rs485.rst
drivers/tty/serial/serial_core.c