2023-11-18 21:36:45

by Lino Sanfilippo

[permalink] [raw]
Subject: Re: [PATCH v4] tty: serial: Add RS422 flag to struct serial_rs485

Hi,

On 15.11.23 03:50, Brenda Streiff wrote:

>
> Documentation/driver-api/serial/serial-rs485.rst could also use an update,
> since it doesn't mention your new flag at all.
>
> The documentation as it is also doesn't give a very good idea of what flags
> userspace might need to set for RS-232 vs RS-422 vs RS-485 (2- or 4-wire).
>
> If I compare this to your original patch set [1] for your hardware, then
> your proposed flag would be used in the following ways, correct?
>
> RS-232: rs485->flags = 0
> RS-422: rs485->flags = SER_RS485_ENABLED|SER_RS485_MODE_RS422
> RS-485 (2-wire half-duplex): rs485->flags = SER_RS485_ENABLED
> RS-485 (4-wire full-duplex): rs485->flags = SER_RS485_ENABLED|SER_RS485_RX_DURING_TX
>
> In iot2040_rs485_config in 8250_exar.c [2] we already seem to have:
> RS-232: rs485->flags = 0
> RS-422: rs485->flags = SER_RS485_ENABLED|SER_RS485_RX_DURING_TX
> RS-485 (2-wire half-duplex?): rs485->flags = SER_RS485_ENABLED
>
> This would seem to create an inconsistency in this API.
>

We can adjust 8250_exar later to also honor SER_RS485_MODE_RS422.
But yes, we have to also keep the current logic (i.e. set the RS422 mode if
SER_RS485_ENABLED|SER_RS485_RX_DURING_TX is set) for backward compatibility.

Regards,
Lino