This patch series adds RS422 flag to switch the serial interface into
RS422 if supported by using "TIOCSRS485" ioctl command.
---
Changes from v5 to v6:
- Split patch into cleanup patch and new feature patch
- [PATCH v6 2/2]:
- Add termination resistors support for RS422
Changes from v4 to v5:
- Revise commit message.
- Delete RS422 checks within uart_set_rs485_termination().
Changes from v3 to v4:
- Include 'linux/const.h' header in '/include/uapi/linux/serial.h'
- Replace BIT() with _BITUL() which defined in
'/include/uapi/linux/const.h'
Changes from v2 to v3:
- Remove "SER_RS422_ENABLED" flag from legacy flags.
- Revise "SER_RS422_ENABLED" into "SER_RS485_MODE_RS422".
- Remove the code which checks the conflicts between SER_RS485_ENABLED
and SER_RS422_ENABLED.
- Add return check in uart_set_rs485_termination().
Changes from v1 to v2:
- Revise the logic that checks whether RS422/RS485 are enabled
simultaneously.
v5: https://lore.kernel.org/all/20231121095122.15948-1-crescentcy.hsieh@moxa.com/
v4: https://lore.kernel.org/all/20231113094136.52003-1-crescentcy.hsieh@moxa.com/
v3: https://lore.kernel.org/all/20231108060719.11775-1-crescentcy.hsieh@moxa.com/
v2: https://lore.kernel.org/all/20231101064404.45711-1-crescentcy.hsieh@moxa.com/
v1: https://lore.kernel.org/all/20231030053632.5109-1-crescentcy.hsieh@moxa.com/
Crescent CY Hsieh (2):
tty: serial: Cleanup the bit shift with macro
tty: serial: Add RS422 flag to struct serial_rs485
drivers/tty/serial/serial_core.c | 6 ++++++
include/uapi/linux/serial.h | 19 +++++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
--
2.34.1
Add "SER_RS485_MODE_RS422" flag to struct serial_rs485, so that serial
port can switch interface into RS422 if supported by using ioctl command
"TIOCSRS485".
By treating RS422 as a mode of RS485, which means while enabling RS422
there are two flags need to be set (SER_RS485_ENABLED and
SER_RS485_MODE_RS422), it would make things much easier. For example
some places that checks for "SER_RS485_ENABLED" won't need to be rewritten.
Signed-off-by: Crescent CY Hsieh <redacted>
---
drivers/tty/serial/serial_core.c | 6 ++++++
include/uapi/linux/serial.h | 2 ++
2 files changed, 8 insertions(+)
@@ -1376,6 +1376,12 @@ static void uart_sanitize_serial_rs485(struct uart_port *port, struct serial_rs4return;}+/* Clear other RS485 flags but SER_RS485_TERMINATE_BUS and return if enabling RS422 */+if(rs485->flags&SER_RS485_MODE_RS422){+rs485->flags&=(SER_RS485_ENABLED|SER_RS485_MODE_RS422|SER_RS485_TERMINATE_BUS);+return;+}+/* Pick sane settings if the user hasn't */if((supported_flags&(SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND))&&!(rs485->flags&SER_RS485_RTS_ON_SEND)==
Isn't it a break if number 3 isn't skipped here as well?
Sorry I might have misunderstood the meaning of "broke userspace".
In this case, does it imply splitting the "cleanup" patch and the "add
feature" patch, or leaving the third bit unused? Or perhaps both?
---
Sincerely,
Crescent Hsieh
Isn't it a break if number 3 isn't skipped here as well?
Sorry I might have misunderstood the meaning of "broke userspace".
In this case, does it imply splitting the "cleanup" patch and the "add
feature" patch, or leaving the third bit unused? Or perhaps both?
You can not redefine existing defines to different values, like you did
here, that changes the user/kernel api of the system.
Luckily this isn't in any released kernel, I'll either revert this after
-rc1 is out, or take a patch from anyone else to do so if they want to
send it now.
thanks,
greg k-h