From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-220.mta0.migadu.com [91.218.175.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E63823890F1 for ; Wed, 19 Aug 2026 08:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.220 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787128133; cv=none; b=m8bkuLLvAbAKkyt+1T6STeEXRIHWoHPsGdqw0OJMMPhMvzTLz4JqAwNuUsRF7ysXE8sq+zRdPNTCdgavjb+cbGGDqQqER4g4eCVYgqVweGSRBAf2qdFfx+3UXmrVHLRkAKIoXsTVpKAFZ6pPerL2kHIy/8JBdsTlujd5KEHL8sI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787128133; c=relaxed/simple; bh=H709P7zX0TCgGrKtzrwenqcGCEVnTLAfpgI+7jdqlBk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Y7kbyhEn8EF1NyDgSydsNP+g0aKepH4yNAP/or6gNlJGhWyYMZl47M+1U8E+vhJM8KY5VTkRIV6L6FgKQchEI1kkmJPXg4RoBuGHZjLA+mV20/0xxTJm0wcNyE0RjPr97Krgclvv2ctO97wXOvcnoTpdpEWlsSGv4RKsfm0+hVE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Dn8xK/dU; arc=none smtp.client-ip=91.218.175.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Dn8xK/dU" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=H709P7zX0TCgGrKtzrwenqcGCEVnTLAfpgI+7jdqlBk=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787128128; v=1; x=1787732928; b=Dn8xK/dUkxlJRk4QiWECSmLkb+73jun9uMlUwAHPJUB9r3ftqJJVjUkVt3i3orYNsQA+W5da kefa8oaQIIFdbZlpITaJkTqeO4lFg7LFfK/BugHeGaqsMn3D5UHj1qxIkP3HbN099WdD3Bht4+g CrQk68k5brMaXyENSBGFNJJo= X-Envelope-To: linux-kernel@vger.kernel.org Received: from fedora.fritz.box (62.216.208.217) by smtp.migadu.com with ESMTPS id a05f70c5e428958c; Wed, 19 Aug 2026 08:28:38 +0000 X-Migadu-Flow: FLOW_OUT From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Thorsten Blum Cc: Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH RESEND v2] x86/boot: Use BASE_BAUD and DEFAULT_SERIAL_PORT Date: Wed, 19 Aug 2026 10:25:29 +0200 Message-ID: <20260819082529.116650-3-thorsten.blum@linux.dev> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1981; i=thorsten.blum@linux.dev; h=from:subject; bh=SQb8ECED1JTFVHDcrCY4sfnxwF9Yzo5dTVY3Rs+jzpI=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFmtGZUNDVriuqaqrDGZFYxL0ySf15b7TSna2GD98siC8 jLGfVs7SlkYxLgYZMUUWR7M+jHDt7SmcpNJxE6YOaxMIEMYuDgFYCLrOxn+yu+w4+JcO4Op903v ZF99wxva67UXTnbqtRCy77l9uYljJyPD79BVS5KSO4U09XW2/f97fUa8HrNTli7zBb6pYUkXo7X 4AA== X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit Replace the hard-coded baud rate and ttyS0 port with the existing BASE_BAUD and DEFAULT_SERIAL_PORT macros. In parse_earlyprintk(), assign the port directly and drop the redundant index variable as well as the bases array to simplify the code. No functional change. Signed-off-by: Thorsten Blum --- Changes in v2: - Drop patch 1/2 from the series after feedback from Dave - v1: https://lore.kernel.org/r/20260411153449.69384-4-thorsten.blum@linux.dev/ --- arch/x86/boot/early_serial_console.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c index 5b83beab89e1..ce6b588dfed0 100644 --- a/arch/x86/boot/early_serial_console.c +++ b/arch/x86/boot/early_serial_console.c @@ -22,6 +22,7 @@ #define DLH 1 /* Divisor latch High */ #define DEFAULT_BAUD 9600 +#define BASE_BAUD (1843200 / 16) static void early_serial_init(int port, int baud) { @@ -33,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); @@ -74,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] == ',') @@ -98,7 +96,6 @@ static void parse_earlyprintk(void) early_serial_init(port, baud); } -#define BASE_BAUD (1843200/16) static unsigned int probe_baud(int port) { unsigned char lcr, dll, dlh;