From 15a33852bb45ee47b46145cf798cf2ab30c6c8ea Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Wed, 15 Apr 2026 21:19:26 +0200 Subject: serial: T8375: call update_serial_console() only once for default tty When there are multiple serial consoles defined; but either none or the last used the 'kernel' CLI option to disply Kernel messages, the GRUB code was called multiple times. By moving the call to the GRUB helpers outside the for loop we gain a single execution of the code path, not that it matters performance wise - but messing with the bootloader should be reduced to a minimum. --- src/conf_mode/system_console.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/conf_mode/system_console.py b/src/conf_mode/system_console.py index 50e5e607b..4985b80c0 100755 --- a/src/conf_mode/system_console.py +++ b/src/conf_mode/system_console.py @@ -30,8 +30,6 @@ airbag.enable() by_bus_dir = '/dev/serial/by-bus' -default_tty_console = ('tty', '0', '') - def get_config(config=None): if config: conf = config @@ -89,6 +87,8 @@ def generate(console): if 'serial-getty' in basename: os.unlink(os.path.join(root, basename)) + # Define a default console on a tty framebuffer + default_tty_console = ('tty', '0', '') if not console or 'device' not in console: grub_util.update_serial_console(*default_tty_console) return None @@ -110,7 +110,6 @@ def generate(console): else: raise ConfigError(f'Device {device} does not support being used as tty') - use_serial_console = False for device, device_config in console['device'].items(): # Do not render getty configuration if specified device is not a TTY. if not is_tty(device): @@ -126,12 +125,9 @@ def generate(console): # get console type ("ttyS" or "ttyAMA") from device (e.g. "ttyS0") console_type = device.rstrip('0123456789') console_num = device[len(console_type):] - grub_util.update_serial_console(console_type, console_num, device_config['speed']) - use_serial_console = True - - if not use_serial_console: - grub_util.update_serial_console(*default_tty_console) + default_tty_console = (console_type, console_num, device_config['speed']) + grub_util.update_serial_console(*default_tty_console) return None def apply(console): -- cgit v1.2.3