Skip to contentSkip to conversation

serial: add PORT_ANY definition

PATCH Superseded Max Filippov 2 participants 2 messages Oct 6, 2023 – Oct 7, 2023 TTY layer and serial drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: add PORT_ANY definition

Current pattern in the linux kernel is that every new serial driver adds one or more new PORT_ definitions because uart_ops::config_port() callback documentation prescribes setting port->type according to the type of port found, or to PORT_UNKNOWN if no port was detected.

When the specific type of the port is not important to the userspace there's no need for a unique PORT_ value, but so far there's no suitable identifier for that case.

Provide generic port type identifier other than PORT_UNKNOWN for ports which type is not important to userspace.

---
 include/uapi/linux/serial.h | 2 ++
 1 file changed, 2 insertions(+)
include/uapi/linux/serial.h +2 -0
index 53bc1af67a41..070e50cf9e1e 100644
@@ -47,6 +47,8 @@ struct serial_struct {
 /*
  * These are the supported serial types.
  */
+/* Generic type identifier for ports which type is not important to userspace. */
+#define PORT_ANY	(-1)
 #define PORT_UNKNOWN	0
 #define PORT_8250	1
 #define PORT_16450	2
Signature · 1 line
2.30.2
#1 lore raw
Quoted 24 lines · Max Filippov

Current pattern in the linux kernel is that every new serial driver adds one or more new PORT_ definitions because uart_ops::config_port() callback documentation prescribes setting port->type according to the type of port found, or to PORT_UNKNOWN if no port was detected.

When the specific type of the port is not important to the userspace there's no need for a unique PORT_ value, but so far there's no suitable identifier for that case.

Provide generic port type identifier other than PORT_UNKNOWN for ports which type is not important to userspace.

---
 include/uapi/linux/serial.h | 2 ++
 1 file changed, 2 insertions(+)
include/uapi/linux/serial.h +0 -0
index 53bc1af67a41..070e50cf9e1e 100644

include/uapi/linux/serial.h struct serial_struct { · line 51

Quoted 5 lines
include/uapi/linux/serial.h +2 -0
@@ -47,6 +47,8 @@ struct serial_struct {
 /*
  * These are the supported serial types.
  */
+/* Generic type identifier for ports which type is not important to userspace. */
+#define PORT_ANY	(-1)

This should be at the end of the list.

And I think we need a better name, "PORT_GENERIC"?

thanks,

greg k-h