Re: [PATCH v6 5/6] serial: Support for RS-485 multipoint addresses
From: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Date: 2022-06-13 22:22:57
Also in:
linux-arch, linux-doc, linux-serial, lkml
Hi, there are some typos in the documentation and comments (see below). On 13.06.22 at 09:52, Ilpo Järvinen wrote:
-5. References +5. Multipoint Addressing +======================== + + The Linux kernel provides addressiong mode for multipoint RS-485 serial
addressiong -> addressing
+ communications line. The addressing mode is enabled with SER_RS485_ADDRB + flag in serial_rs485. Struct serial_rs485 fhas two additional flags and
fhas -> has
+ fields for enabling reveive and destination addresses.
reveive -> receive
quoted hunk ↗ jump to hunk
+ + Address mode flags: + - SER_RS485_ADDRB: Enabled addressing mode (sets also ADDRB in termios). + - SER_RS485_ADDR_RECV: Receive (filter) address enabled. + - SER_RS485_ADDR_DEST: Set destination address. + + Address fields (enabled with corresponding SER_RS485_ADDR_* flag): + - addr_recv: Receive address. + - addr_dest: Destination address. + + Once a receive address is set, the communication can occur only with the + particular device and other peers are filtered out. It is left up to the + receiver side to enforce the filtering. Receive address will be cleared + if SER_RS485_ADDR_RECV is not set. + + Note: not all devices supporting RS485 support multipoint addressing. + +6. References ============= [1] include/uapi/linux/serial.hdiff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 76bb1b77b06e..bc18018e8d4b 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c@@ -1294,6 +1294,17 @@ static int uart_check_rs485_flags(struct uart_port *port, struct serial_rs485 *r if (flags & ~port->rs485_supported->flags) return -EINVAL; + /* Asking for address w/o addressing mode? */ + if (!(rs485->flags & SER_RS485_ADDRB) && + (rs485->flags & (SER_RS485_ADDR_RECV|SER_RS485_ADDR_DEST))) + return -EINVAL; + + /* Address gived but not enabled? */
gived -> given Regards, Lino