[PATCH] serial: 8250: don't register ports that have no hardware
Lucas Tanure <[email protected]>
| Newsgroups | gmane.linux.serial,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
The 8250 driver creates a fixed set of port slots at boot and registers a ttyS device for each one, even when the slot describes no hardware. On device tree platforms those slots are empty, but they still take the ttyS0..ttyS3 names. New Amlogic SoCs (S4, T7) name their real UARTs ttyS as well. With both drivers built in, as in arm64 defconfig, the real port fails to bind: sysfs: cannot create duplicate filename '/class/tty/ttyS0' meson_uart fe078000.serial: Cannot register tty device on line 0 Skip slots that have no I/O and no memory address. Legacy x86 slots come with resources and are not affected. Signed-off-by: Lucas Tanure <[email protected]> Assisted-by: Claude:claude-fable-5 --- drivers/tty/serial/8250/8250_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index f49862d90eeb..e66e0cdbb210 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -378,6 +378,14 @@ void __init serial8250_register_ports(struct uart_driver *drv, struct device *de if (up->port.dev) continue; + /* + * Skip slots that describe no hardware: they would only + * take up ttyS<n> names. Real ports get their node when + * they claim a slot in serial8250_register_8250_port(). + */ + if (!up->port.iobase && !up->port.mapbase && !up->port.membase) + continue; + up->port.dev = dev; if (uart_console_registered(&up->port)) -- 2.55.0