From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05E833D1AA6 for ; Fri, 15 May 2026 11:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778843495; cv=none; b=IY+JDtsYlbmsJxr3LM0LhuDVASC2AZ0rKrEoyLzHE5CZfiE/RAOaQj8I/wYMO6eMbEWoHTsq8RPdTtalZh26HRxxO9hrnXnMZTNDdz2awNxiUR9wMMoAJ5ZNJirszdA+FPhkI5ijJxfhfXb9VEG1KusfcGUBKShz5WRY22MfZsg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778843495; c=relaxed/simple; bh=UTc4/agqkbrWW4lseSCvGhPCe+LPBaeNK+B+8yBxYnY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Jr9p5tjdSca7AoosdGxfXOBNNKwIBGYE9YONDf8PLDwos/1/iDQ+WQ5Is36BT48sP5YDRpr4J5fF0NFlYiQ+5s7RHEgfIH7veSEHIzLx7qt8U/od/VlsN0JyvnAM1+6gQjIZ9aoc1XzDMRDpLTo4ViRJepz4gFLIytwROeLndb0= 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=pU4DTq8j; arc=none smtp.client-ip=95.215.58.172 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="pU4DTq8j" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1778843490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=C/tYMiSOPvSHewDKK4873Vnq6Au7wy6egv8eCN/xow8=; b=pU4DTq8joZhl+gq4UWY8lMBLX1wJ7YnuV+StDqnAXkY4B6SeW8TaJaJwi0Qr8pZ8BdnBdf GvekfaYbjdSaCiy1YAtkqpDJkA6lCllyrak2/kgxMlM3vfUh95sc/q2xj3E0Mb+HY/zIEE UtfRkOSPIPLNXNBRHTXv/d7JDxxpHKg= From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Thorsten Blum Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] x86/boot: use BASE_BAUD and DEFAULT_SERIAL_PORT Date: Fri, 15 May 2026 13:10:40 +0200 Message-ID: <20260515111040.536150-3-thorsten.blum@linux.dev> 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=1957; i=thorsten.blum@linux.dev; h=from:subject; bh=UTc4/agqkbrWW4lseSCvGhPCe+LPBaeNK+B+8yBxYnY=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFls/w2Md9tL9TfZp8fz7Dhno/fpMrPFJjeekNWFuh97D 0f17FbuKGVhEONikBVTZHkw68cM39Kayk0mETth5rAygQxh4OIUgIl842X4w/Vv8r0vU98cuS63 XfnFdO85m2w+X2qVmP9mTVr+Y96HUTcYGa4rqQZ5bFk6g8eYZU1R2dJrV1jEzv3t3/f9oeWThTy OS9gB X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 --- Changes in v2: - Drop patch 1/2 from the series after feedback from Dave - v1: https://lore.kernel.org/lkml/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 023bf1c3de8b..caf481cdd415 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;