[PATCH v1 5/6] serial: 8250: hub6: Add cleanup code
From: Uwe Kleine-König
Date: Fri Jul 31 2026 - 05:42:05 EST
At module load time a platform device is registered. That should be
undone when the module is unloaded.
Fixes: ec9f47cd6a14 ("[PATCH] Serial: Split 8250 port table")
Signed-off-by: Uwe Kleine-König <ukleinek@xxxxxxxxxx>
---
drivers/tty/serial/8250/8250.h | 2 ++
drivers/tty/serial/8250/8250_hub6.c | 5 +++++
drivers/tty/serial/8250/8250_platform.c | 5 ++++-
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 39d72f1480c0..01fed8d44b7b 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -317,8 +317,10 @@ static inline void serial8250_pnp_exit(void) { }
#ifdef CONFIG_SERIAL_8250_HUB6
int serial8250_hub6_init(void);
+void serial8250_hub6_exit(void);
#else
static inline int serial8250_hub6_init(void) { return 0; }
+static inline void serial8250_hub6_exit(void) { }
#endif
#ifdef CONFIG_SERIAL_8250_RSA
diff --git a/drivers/tty/serial/8250/8250_hub6.c b/drivers/tty/serial/8250/8250_hub6.c
index 3e548530ec4e..55320b794165 100644
--- a/drivers/tty/serial/8250/8250_hub6.c
+++ b/drivers/tty/serial/8250/8250_hub6.c
@@ -53,3 +53,8 @@ int __init serial8250_hub6_init(void)
{
return platform_device_register(&hub6_device);
}
+
+int __init_or_module serial8250_hub6_exit(void)
+{
+ return platform_device_unregister(&hub6_device);
+}
diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c
index e8524d545de9..72076ccb5bde 100644
--- a/drivers/tty/serial/8250/8250_platform.c
+++ b/drivers/tty/serial/8250/8250_platform.c
@@ -326,7 +326,7 @@ static int __init serial8250_init(void)
serial8250_isa_devs = platform_device_alloc("serial8250", PLAT8250_DEV_LEGACY);
if (!serial8250_isa_devs) {
ret = -ENOMEM;
- goto unreg_pnp;
+ goto unreg_hub6;
}
ret = platform_device_add(serial8250_isa_devs);
@@ -342,6 +342,8 @@ static int __init serial8250_init(void)
platform_device_del(serial8250_isa_devs);
put_dev:
platform_device_put(serial8250_isa_devs);
+unreg_hub6:
+ serial8250_hub6_exit();
unreg_pnp:
serial8250_pnp_exit();
unreg_uart_drv:
@@ -369,6 +371,7 @@ static void __exit serial8250_exit(void)
platform_driver_unregister(&serial8250_isa_driver);
platform_device_unregister(isa_dev);
+ serial8250_hub6_exit();
serial8250_pnp_exit();
#ifdef CONFIG_SPARC
--
2.55.0.11.g153666a7d9bb