From a300273c458ca32666f5bc6c1b3eb3a7cca206ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig=20=28The=20Capable=20Hub=29?= Date: Fri, 14 Aug 2026 11:19:32 +0200 Subject: [PATCH] serial: 8250: hub6: Add cleanup code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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") Acked-by: Andy Shevchenko Signed-off-by: Uwe Kleine-König (The Capable Hub) Link: https://patch.msgid.link/4f1903ff2907f3e8bbabce345f628771e0bbd4e1.1786697789.git.u.kleine-koenig@baylibre.com Signed-off-by: Greg Kroah-Hartman --- 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 54b4d5a5e36e..4dfe8c65a3d8 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -324,8 +324,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..4d4c54c951cb 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); } + +void __init_or_module serial8250_hub6_exit(void) +{ + platform_device_unregister(&hub6_device); +} diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c index 3a2dff9ce7b7..0570366a71d0 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