diff mbox series

[3/3] serial: 8250: skip platform device registration with no runtime ports

Message ID 20221013081748.25699-3-martin@geanix.com
State New
Headers show
Series [1/3] serial: 8250: allow use of non-runtime configured uart ports | expand

Commit Message

Martin Hundebøll Oct. 13, 2022, 8:17 a.m. UTC
Skip registration of the platform device used for built-in ports, if no
such ports are configured/created.

Signed-off-by: Martin Hundebøll <martin@geanix.com>
---
 drivers/tty/serial/8250/8250_core.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index ba48431ec6e2..3161f32c1e90 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -1182,6 +1182,14 @@  static int __init serial8250_init(void)
 	if (ret)
 		goto out;
 
+	if (nr_uarts == 0) {
+		ret = platform_driver_register(&serial8250_isa_driver);
+		if (ret)
+			goto unreg_uart_drv;
+
+		goto out;
+	}
+
 	ret = serial8250_pnp_init();
 	if (ret)
 		goto unreg_uart_drv;
@@ -1230,9 +1238,11 @@  static void __exit serial8250_exit(void)
 	serial8250_isa_devs = NULL;
 
 	platform_driver_unregister(&serial8250_isa_driver);
-	platform_device_unregister(isa_dev);
 
-	serial8250_pnp_exit();
+	if (nr_uarts) {
+		platform_device_unregister(isa_dev);
+		serial8250_pnp_exit();
+	}
 
 #ifdef CONFIG_SPARC
 	sunserial_unregister_minors(&serial8250_reg, UART_NR);