Skip to contentSkip to conversation

tty: serial: Fix bit order in RS485 flag definitions

PATCH Superseded Christoph Niedermaier 2 participants 3 messages Jan 18, 2024 – Jan 19, 2024 TTY layer and serial drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tty: serial: Fix bit order in RS485 flag definitions

Since the commit 93f3350c46fa ("RS485: fix inconsistencies in the meaning of some variables"), the definition for bit 3 has been removed. But with the switch to bit shift macros in commit 76ac8e29855b ("tty:
serial: Cleanup the bit shift with macro"), this gap wasn't preserved. To avoid a break in user/kernel api of the system skip bit 3 again and add a placeholder comment.

Fixes 76ac8e29855b ("tty: serial: Cleanup the bit shift with macro")
Fixes 6056f20f27e9 ("tty: serial: Add RS422 flag to struct serial_rs485")

---
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Crescent CY Hsieh <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Lukas Wunner <[email protected]>
Cc: Lino Sanfilippo <[email protected]>
Cc: Hugo Villeneuve <[email protected]>
To: [email protected]
To: [email protected]
---
V2: - Fix typo
- Add Fixes tags

---
 include/uapi/linux/serial.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
include/uapi/linux/serial.h +7 -6
index 9086367db043..de9b4733607e 100644
@@ -145,12 +145,13 @@ struct serial_rs485 {
 #define SER_RS485_ENABLED		_BITUL(0)
 #define SER_RS485_RTS_ON_SEND		_BITUL(1)
 #define SER_RS485_RTS_AFTER_SEND	_BITUL(2)
-#define SER_RS485_RX_DURING_TX		_BITUL(3)
-#define SER_RS485_TERMINATE_BUS		_BITUL(4)
-#define SER_RS485_ADDRB			_BITUL(5)
-#define SER_RS485_ADDR_RECV		_BITUL(6)
-#define SER_RS485_ADDR_DEST		_BITUL(7)
-#define SER_RS485_MODE_RS422		_BITUL(8)
+/* Placeholder for bit 3: SER_RS485_RTS_BEFORE_SEND, which isn't used anymore */
+#define SER_RS485_RX_DURING_TX		_BITUL(4)
+#define SER_RS485_TERMINATE_BUS		_BITUL(5)
+#define SER_RS485_ADDRB			_BITUL(6)
+#define SER_RS485_ADDR_RECV		_BITUL(7)
+#define SER_RS485_ADDR_DEST		_BITUL(8)
+#define SER_RS485_MODE_RS422		_BITUL(9)
 
 	__u32	delay_rts_before_send;
 	__u32	delay_rts_after_send;
Signature · 1 line
2.11.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Christoph Niedermaier

Since the commit 93f3350c46fa ("RS485: fix inconsistencies in the meaning of some variables"), the definition for bit 3 has been removed. But with the switch to bit shift macros in commit 76ac8e29855b ("tty:
serial: Cleanup the bit shift with macro"), this gap wasn't preserved. To avoid a break in user/kernel api of the system skip bit 3 again and add a placeholder comment.

Fixes 76ac8e29855b ("tty: serial: Cleanup the bit shift with macro")
Fixes 6056f20f27e9 ("tty: serial: Add RS422 flag to struct serial_rs485")

---

This triple dash is superfluous and will likely break git am.

Quoted 8 lines

Cc: Greg Kroah-Hartman <[email protected]>
Cc: Crescent CY Hsieh <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Lukas Wunner <[email protected]>
Cc: Lino Sanfilippo <[email protected]>
Cc: Hugo Villeneuve <[email protected]>
To: [email protected]
To: [email protected]

"To" is not supported here, IMO.

When you fix that:

Quoted 31 lines

---
V2: - Fix typo
- Add Fixes tags

---
  include/uapi/linux/serial.h | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
include/uapi/linux/serial.h +7 -6
index 9086367db043..de9b4733607e 100644
@@ -145,12 +145,13 @@ struct serial_rs485 {
  #define SER_RS485_ENABLED		_BITUL(0)
  #define SER_RS485_RTS_ON_SEND		_BITUL(1)
  #define SER_RS485_RTS_AFTER_SEND	_BITUL(2)
-#define SER_RS485_RX_DURING_TX		_BITUL(3)
-#define SER_RS485_TERMINATE_BUS		_BITUL(4)
-#define SER_RS485_ADDRB			_BITUL(5)
-#define SER_RS485_ADDR_RECV		_BITUL(6)
-#define SER_RS485_ADDR_DEST		_BITUL(7)
-#define SER_RS485_MODE_RS422		_BITUL(8)
+/* Placeholder for bit 3: SER_RS485_RTS_BEFORE_SEND, which isn't used anymore */
+#define SER_RS485_RX_DURING_TX		_BITUL(4)
+#define SER_RS485_TERMINATE_BUS		_BITUL(5)
+#define SER_RS485_ADDRB			_BITUL(6)
+#define SER_RS485_ADDR_RECV		_BITUL(7)
+#define SER_RS485_ADDR_DEST		_BITUL(8)
+#define SER_RS485_MODE_RS422		_BITUL(9)
 
  	__u32	delay_rts_before_send;
  	__u32	delay_rts_after_send;
Signature · 2 lines
js
suse labs
#2 lore raw

From: Jiri Slaby [mailto:[email protected]]
Sent: Friday, January 19, 2024 7:36 AM

Quoted 8 lines · Christoph Niedermaier
Quoted 7 lines

Since the commit 93f3350c46fa ("RS485: fix inconsistencies in the meaning of some variables"), the definition for bit 3 has been removed. But with the switch to bit shift macros in commit 76ac8e29855b ("tty:
serial: Cleanup the bit shift with macro"), this gap wasn't preserved. To avoid a break in user/kernel api of the system skip bit 3 again and add a placeholder comment.

Quoted 6 lines
Quoted 4 lines
Fixes 76ac8e29855b ("tty: serial: Cleanup the bit shift with macro")
Fixes 6056f20f27e9 ("tty: serial: Add RS422 flag to struct serial_rs485")

---

This triple dash is superfluous and will likely break git am.

OK.

Quoted 10 lines
Quoted 8 lines

Cc: Greg Kroah-Hartman <[email protected]>
Cc: Crescent CY Hsieh <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Lukas Wunner <[email protected]>
Cc: Lino Sanfilippo <[email protected]>
Cc: Hugo Villeneuve <[email protected]>
To: [email protected]
To: [email protected]

"To" is not supported here, IMO.

OK.

Quoted 2 lines

When you fix that:

I will create a version 3.

[...]

Regards
Christoph