[PATCH 2/2] x86/boot: use BASE_BAUD and DEFAULT_SERIAL_PORT
From: Thorsten Blum
Date: Sat Apr 11 2026 - 11:36:16 EST
Replace the hard-coded divisor and ttyS0 port with the existing
BASE_BAUD and DEFAULT_SERIAL_PORT macros.
In parse_earlyprintk(), assign 'port' directly and drop the redundant
index variable as well as the 'bases' array to simplify the code.
Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
---
arch/x86/boot/early_serial_console.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index fe0c8c1022f4..420f50f3bd1e 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -34,7 +34,7 @@ static void early_serial_init(int port, int baud)
outb(0, port + FCR); /* no fifo */
outb(0x3, port + MCR); /* DTR + RTS */
- divisor = 115200 / baud;
+ divisor = BASE_BAUD / baud;
c = inb(port + LCR);
outb(c | DLAB, port + LCR);
outb(divisor & 0xff, port + DLL);
@@ -75,16 +75,13 @@ static void parse_earlyprintk(void)
else
pos = e - arg;
} else if (!strncmp(arg + pos, "ttyS", 4)) {
- static const int bases[] = { 0x3f8, 0x2f8 };
- int idx = 0;
-
/* += strlen("ttyS"); */
pos += 4;
if (arg[pos++] == '1')
- idx = 1;
-
- port = bases[idx];
+ port = 0x2f8; /* ttyS1 */
+ else
+ port = DEFAULT_SERIAL_PORT;
}
if (arg[pos] == ',')