From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
"Abinash Singh" <abinashsinghlalotra@gmail.com>,
"Kees Cook" <kees@kernel.org>, "Gerhard Engleder" <eg@keba.com>,
"Lukas Wunner" <lukas@wunner.de>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Binbin Zhou" <zhoubinbin@loongson.cn>,
"Rong Zhang" <rongrong@oss.cipunited.com>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Haowei Zheng" <zhenghaowei@loongson.cn>,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: [PATCH v1 4/6] serial: 8250: Fix corner case for port matching
Date: Fri, 31 Jul 2026 11:39:07 +0200 [thread overview]
Message-ID: <7c105c23bcb12328536cda06d52e6c9cec7d7d22.1785489518.git.ukleinek@kernel.org> (raw)
In-Reply-To: <cover.1785489518.git.ukleinek@kernel.org>
In the case CONFIG_SERIAL_8250=y + CONFIG_SERIAL_8250_HUB6=m
hub6_match_port() evaluates statically to false in
serial8250_match_port() which is a bug and a change in behavior compared
to before commit 7ab80d1e7243 ("serial: 8250: fix compile error with
hub6_match_port() when compiled as a module").
To make the comparison correct, the dummy implementation of
hub6_match_port() must only be used if CONFIG_SERIAL_8250_HUB6 is
disabled. Then as there is a bidirectional dependency between
8250_hub6.c and 8250_core.c, put both in the same module.
Fixes: 7ab80d1e7243 ("serial: 8250: fix compile error with hub6_match_port() when compiled as a module")
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
---
drivers/tty/serial/8250/8250.h | 8 +++++++-
drivers/tty/serial/8250/8250_hub6.c | 8 +-------
drivers/tty/serial/8250/8250_platform.c | 4 ++++
drivers/tty/serial/8250/Kconfig | 4 ++--
drivers/tty/serial/8250/Makefile | 2 +-
5 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index b62f88eec881..39d72f1480c0 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -315,6 +315,12 @@ static inline int serial8250_pnp_init(void) { return 0; }
static inline void serial8250_pnp_exit(void) { }
#endif
+#ifdef CONFIG_SERIAL_8250_HUB6
+int serial8250_hub6_init(void);
+#else
+static inline int serial8250_hub6_init(void) { return 0; }
+#endif
+
#ifdef CONFIG_SERIAL_8250_RSA
void univ8250_rsa_support(struct uart_ops *ops, const struct uart_ops *core_ops);
void rsa_enable(struct uart_8250_port *up);
@@ -335,7 +341,7 @@ int fintek_8250_probe(struct uart_8250_port *uart);
static inline int fintek_8250_probe(struct uart_8250_port *uart) { return 0; }
#endif
-#if IS_REACHABLE(CONFIG_SERIAL_8250_HUB6)
+#if IS_ENABLED(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)
diff --git a/drivers/tty/serial/8250/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c
index b6767633c966..3e548530ec4e 100644
--- a/drivers/tty/serial/8250/8250_hub6.c
+++ b/drivers/tty/serial/8250/8250_hub6.c
@@ -49,13 +49,7 @@ bool hub6_match_port(const struct uart_port *port1, const struct uart_port *port
}
EXPORT_SYMBOL_GPL(hub6_match_port);
-static int __init hub6_init(void)
+int __init serial8250_hub6_init(void)
{
return platform_device_register(&hub6_device);
}
-
-module_init(hub6_init);
-
-MODULE_AUTHOR("Russell King");
-MODULE_DESCRIPTION("8250 serial probe module for Hub6 cards");
-MODULE_LICENSE("GPL");
diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c
index 5a0bc1fae11d..e8524d545de9 100644
--- a/drivers/tty/serial/8250/8250_platform.c
+++ b/drivers/tty/serial/8250/8250_platform.c
@@ -319,6 +319,10 @@ static int __init serial8250_init(void)
if (ret)
goto unreg_uart_drv;
+ ret = serial8250_hub6_init();
+ if (ret)
+ goto unreg_pnp;
+
serial8250_isa_devs = platform_device_alloc("serial8250", PLAT8250_DEV_LEGACY);
if (!serial8250_isa_devs) {
ret = -ENOMEM;
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index fc3e58d62233..00c2ced12717 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -294,8 +294,8 @@ config SERIAL_8250_EXAR_ST16C554
will be called 8250_exar_st16c554.
config SERIAL_8250_HUB6
- tristate "Support Hub6 cards"
- depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
+ bool "Support Hub6 cards"
+ depends on SERIAL_8250_MANY_PORTS && ISA
help
Say Y here if you have a HUB6 serial board.
diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile
index 6d21402b4435..416c32e3aba2 100644
--- a/drivers/tty/serial/8250/Makefile
+++ b/drivers/tty/serial/8250/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_SERIAL_8250) += 8250.o
8250-y := 8250_core.o
8250-y += 8250_platform.o
8250-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o
+8250-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
obj-$(CONFIG_SERIAL_8250) += 8250_base.o
8250_base-y := 8250_port.o
@@ -35,7 +36,6 @@ obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o
obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o
-obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
obj-$(CONFIG_SERIAL_8250_INGENIC) += 8250_ingenic.o
obj-$(CONFIG_SERIAL_8250_IOC3) += 8250_ioc3.o
obj-$(CONFIG_SERIAL_8250_KEBA) += 8250_keba.o
--
2.55.0.11.g153666a7d9bb
next prev parent reply other threads:[~2026-07-31 9:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 9:39 [PATCH v1 0/6] serial: Some yak shaving Uwe Kleine-König
2026-07-31 9:39 ` [PATCH v1 1/6] serial: txx9: Drop noop probe function and dangerous remove callback Uwe Kleine-König
2026-07-31 9:39 ` [PATCH v1 2/6] serial: txx9: Drop usage of uart_match_port() Uwe Kleine-König
2026-08-03 14:46 ` Greg Kroah-Hartman
2026-08-03 18:57 ` Uwe Kleine-König
2026-08-03 17:27 ` Ilpo Järvinen
2026-08-03 18:59 ` Uwe Kleine-König
2026-07-31 9:39 ` [PATCH v1 3/6] serial: 8250: Make uart_match_port() a 8250 specific function Uwe Kleine-König
2026-08-03 17:23 ` Ilpo Järvinen
2026-08-03 19:22 ` Hugo Villeneuve
2026-07-31 9:39 ` Uwe Kleine-König [this message]
2026-07-31 9:39 ` [PATCH v1 5/6] serial: 8250: hub6: Add cleanup code Uwe Kleine-König
2026-07-31 9:39 ` [PATCH v1 6/6] serial: 8250: pnp: Annotate init and exit functions for conditional discarding Uwe Kleine-König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c105c23bcb12328536cda06d52e6c9cec7d7d22.1785489518.git.ukleinek@kernel.org \
--to=ukleinek@kernel.org \
--cc=abinashsinghlalotra@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=chenhuacai@kernel.org \
--cc=eg@keba.com \
--cc=gregkh@linuxfoundation.org \
--cc=hvilleneuve@dimonoff.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=rdunlap@infradead.org \
--cc=rongrong@oss.cipunited.com \
--cc=zhenghaowei@loongson.cn \
--cc=zhoubinbin@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®