From 3d406299d8829747fe2e8692f4c29fe3dc1d101f Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Thu, 21 May 2026 14:16:47 -0400 Subject: [PATCH] serial: 8250_hub6: add hub6_match_port() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the entire hub6 related match port check into its own function in 8250_hub6.c and add a stub for the case when hub6 code is not even built into kernel. Suggested-by: Ilpo Järvinen Signed-off-by: Hugo Villeneuve Link: https://patch.msgid.link/20260521-tty-upio-v3-1-bf74567994a0@dimonoff.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250.h | 7 +++++++ drivers/tty/serial/8250/8250_hub6.c | 6 ++++++ drivers/tty/serial/serial_core.c | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index 77fe0588fd6b..9d1068d0489d 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -334,6 +334,13 @@ int fintek_8250_probe(struct uart_8250_port *uart); static inline int fintek_8250_probe(struct uart_8250_port *uart) { return 0; } #endif +#ifdef CONFIG_SERIAL_8250_HUB6 +bool hub6_match_port(const struct uart_port *port1, const struct uart_port *port2); +#else +static inline bool hub6_match_port(const struct uart_port *port1, const struct uart_port *port2) +{ return false; } +#endif + #ifdef CONFIG_ARCH_OMAP1 #include static inline int is_omap1_8250(struct uart_8250_port *pt) diff --git a/drivers/tty/serial/8250/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c index 273f59b9bca5..eae32c924e29 100644 --- a/drivers/tty/serial/8250/8250_hub6.c +++ b/drivers/tty/serial/8250/8250_hub6.c @@ -41,6 +41,12 @@ static struct platform_device hub6_device = { }, }; +bool hub6_match_port(const struct uart_port *port1, const struct uart_port *port2) +{ + return port1->iobase == port2->iobase && port1->hub6 == port2->hub6; +} +EXPORT_SYMBOL_GPL(hub6_match_port); + static int __init hub6_init(void) { return platform_device_register(&hub6_device); diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index a530ad372b43..965ba0335a36 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -33,6 +33,7 @@ #include #include "serial_base.h" +#include "8250/8250.h" /* For hub6_match_port() */ /* * This is used to lock changes in serial line configuration. @@ -3213,8 +3214,7 @@ bool uart_match_port(const struct uart_port *port1, case UPIO_PORT: return port1->iobase == port2->iobase; case UPIO_HUB6: - return port1->iobase == port2->iobase && - port1->hub6 == port2->hub6; + return hub6_match_port(port1, port2); case UPIO_MEM: case UPIO_MEM16: case UPIO_MEM32: