Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: 8250_platform: Explicitly show we initialise ISA ports only once

serial8250_isa_init_ports() uses home grown approach to make itself
a singleton. Instead, explicitly show that we initialise ISA ports
once by providing a helper function which calls the original function
via DO_ONCE() macro.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240606184841.3102545-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
efa6b0a1 f0a17485

+7 -6
+7 -6
drivers/tty/serial/8250/8250_platform.c
··· 9 9 #include <linux/array_size.h> 10 10 #include <linux/module.h> 11 11 #include <linux/moduleparam.h> 12 + #include <linux/once.h> 12 13 #include <linux/platform_device.h> 13 14 14 15 #include <linux/serial_8250.h> ··· 54 53 } 55 54 EXPORT_SYMBOL(serial8250_set_isa_configurator); 56 55 57 - void __init serial8250_isa_init_ports(void) 56 + static void __init __serial8250_isa_init_ports(void) 58 57 { 59 - static int first = 1; 60 58 int i, irqflag = 0; 61 - 62 - if (!first) 63 - return; 64 - first = 0; 65 59 66 60 if (nr_uarts > UART_NR) 67 61 nr_uarts = UART_NR; ··· 96 100 97 101 serial_base_add_isa_preferred_console(serial8250_reg.dev_name, i); 98 102 } 103 + } 104 + 105 + void __init serial8250_isa_init_ports(void) 106 + { 107 + DO_ONCE(__serial8250_isa_init_ports); 99 108 } 100 109 101 110 /*