From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 7814B2D0618 for ; Fri, 6 Feb 2026 16:50:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396613; cv=none; b=jjRuLpJSTRcf242o9zNT4wtwgpNz90RTqTNvUOxO9D2d+aIMbssjnynL4KXjntaexvftv0LxXcyKHWeo8ThOwc3F4oLuiIParpQTuB/DJ5DIxd4V/k9xU0gMZKayamTiYk5brbnIFKuYAx6GUxF1Oj65L6kMRkOx23ktYSpO8qQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396613; c=relaxed/simple; bh=k0NuY8NMbvAPaftSSji5gNyWBdsp4Wbzvztpc4ihOR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=izg89g/K+du+K51UJmE8QERazAdfp373eaEmJLjNxXusS5Wae973ai3j9Q6Ue1TvphsAbwSya20FeaFzLi4fX/tP8GOgZRZbyDpHijq/hUX1NNXIZxcd/JWdXdy5uZIqmGlj2mZ4xtMszAIBR1mGmhZyAR6Szq6Txf+CBA9vKsE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=XHtb8ej1; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=XHtb8ej1; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="XHtb8ej1"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="XHtb8ej1" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id 9E8353E6D1; Fri, 6 Feb 2026 16:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396611; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7swn1Q3wmHsarVmUOy8iorPthefm0jJSeC4+L/2cp4k=; b=XHtb8ej1zomNCVa9na7QrxbWDS7ygc3Woaa5PFKUtVvwvlPSHgJKtu3VMz6MdjkMS0TZrC e2VX/8F6NcYNIYL337Y1Z84Whc+z0bzc5Mu6LdGL/0T9mPSqAKpKH+B4bXR6k9zuf2Zlw9 6GNbBIXb9KV2vwXDVUIpJuDpN2UQzaI= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=XHtb8ej1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396611; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7swn1Q3wmHsarVmUOy8iorPthefm0jJSeC4+L/2cp4k=; b=XHtb8ej1zomNCVa9na7QrxbWDS7ygc3Woaa5PFKUtVvwvlPSHgJKtu3VMz6MdjkMS0TZrC e2VX/8F6NcYNIYL337Y1Z84Whc+z0bzc5Mu6LdGL/0T9mPSqAKpKH+B4bXR6k9zuf2Zlw9 6GNbBIXb9KV2vwXDVUIpJuDpN2UQzaI= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 1/8] printk: Rename struct console_cmdline to preferred_console Date: Fri, 6 Feb 2026 17:49:55 +0100 Message-ID: <20260206165002.496724-2-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[7]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[pathway.suse.cz:helo,suse.com:mid,suse.com:dkim,suse.com:email]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; DNSWL_BLOCKED(0.00)[2a07:de40:b2bf:1b::12bd:from]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Flag: YES X-Spamd-Bar: ++++++++++++++++ X-Rspamd-Queue-Id: 9E8353E6D1 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: add header X-Spam-Level: **************** X-Spam-Score: 16.67 X-Spam: Yes Content-Type: text/plain; charset="utf-8" The structure 'console_cmdline' was originally intended to store details about consoles defined on the kernel command line. However, its usage has since expanded; it now stores information for consoles preferred via SPCR, device tree, or by particular platforms, e.g. XEN. The current naming is misleading as it implies the configuration only originates from the command line. Rename the structure and associated artifacts to better reflect their current purpose, for example: - struct console_cmdline c -> struct preferred_console pc - console_cmdline[] -> preferred_consoles[] - console_cmdline.h -> console_register.h - c -> pc Additionally, renaming the header file to console_register.h would eventually allow to decouple console registration logic from the monolithic printk.c. Finally, renaming the local variable from "c" to "pc" helps to distinguish it from struct console variables. Note that "c" is used for struct console in some code, for example see vt_console_device() function definition. Signed-off-by: Petr Mladek --- kernel/printk/braille.c | 10 +-- kernel/printk/braille.h | 10 +-- .../{console_cmdline.h =3D> console_register.h} | 6 +- kernel/printk/printk.c | 84 ++++++++++--------- 4 files changed, 56 insertions(+), 54 deletions(-) rename kernel/printk/{console_cmdline.h =3D> console_register.h} (83%) diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c index 17a9591e54ff..9d21a2bb1d38 100644 --- a/kernel/printk/braille.c +++ b/kernel/printk/braille.c @@ -6,7 +6,7 @@ #include #include =20 -#include "console_cmdline.h" +#include "console_register.h" #include "braille.h" =20 int _braille_console_setup(char **str, char **brl_options) @@ -35,14 +35,14 @@ int _braille_console_setup(char **str, char **brl_optio= ns) } =20 int -_braille_register_console(struct console *console, struct console_cmdline = *c) +_braille_register_console(struct console *console, struct preferred_consol= e *pc) { int rtn =3D 0; =20 - if (c->brl_options) { + if (pc->brl_options) { console->flags |=3D CON_BRL; - rtn =3D braille_register_console(console, c->index, c->options, - c->brl_options); + rtn =3D braille_register_console(console, pc->index, pc->options, + pc->brl_options); } =20 return rtn; diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h index 123154f86304..55cd3178a17a 100644 --- a/kernel/printk/braille.h +++ b/kernel/printk/braille.h @@ -5,9 +5,9 @@ #ifdef CONFIG_A11Y_BRAILLE_CONSOLE =20 static inline void -braille_set_options(struct console_cmdline *c, char *brl_options) +braille_set_options(struct preferred_console *pc, char *brl_options) { - c->brl_options =3D brl_options; + pc->brl_options =3D brl_options; } =20 /* @@ -21,7 +21,7 @@ int _braille_console_setup(char **str, char **brl_options); =20 int -_braille_register_console(struct console *console, struct console_cmdline = *c); +_braille_register_console(struct console *console, struct preferred_consol= e *pc); =20 int _braille_unregister_console(struct console *console); @@ -29,7 +29,7 @@ _braille_unregister_console(struct console *console); #else =20 static inline void -braille_set_options(struct console_cmdline *c, char *brl_options) +braille_set_options(struct preferred_console *pc, char *brl_options) { } =20 @@ -40,7 +40,7 @@ _braille_console_setup(char **str, char **brl_options) } =20 static inline int -_braille_register_console(struct console *console, struct console_cmdline = *c) +_braille_register_console(struct console *console, struct preferred_consol= e *pc) { return 0; } diff --git a/kernel/printk/console_cmdline.h b/kernel/printk/console_regist= er.h similarity index 83% rename from kernel/printk/console_cmdline.h rename to kernel/printk/console_register.h index 0ab573b6d4dc..9ab3e1cc749b 100644 --- a/kernel/printk/console_cmdline.h +++ b/kernel/printk/console_register.h @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _CONSOLE_CMDLINE_H -#define _CONSOLE_CMDLINE_H +#ifndef _CONSOLE_REGISTER_H +#define _CONSOLE_REGISTER_H =20 -struct console_cmdline +struct preferred_console { char name[16]; /* Name of the driver */ int index; /* Minor dev. to use */ diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 1d765ad242b8..86a908e74445 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -58,7 +58,7 @@ #include =20 #include "printk_ringbuffer.h" -#include "console_cmdline.h" +#include "console_register.h" #include "braille.h" #include "internal.h" =20 @@ -360,9 +360,9 @@ static int console_locked; * Array of consoles built from command line options (console=3D) */ =20 -#define MAX_CMDLINECONSOLES 8 +#define MAX_PREFERRED_CONSOLES 8 =20 -static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES]; +static struct preferred_console preferred_consoles[MAX_PREFERRED_CONSOLES]; =20 static int preferred_console =3D -1; int console_set_on_cmdline; @@ -2491,7 +2491,7 @@ asmlinkage __visible void early_printk(const char *fm= t, ...) } #endif =20 -static void set_user_specified(struct console_cmdline *c, bool user_specif= ied) +static void set_user_specified(struct preferred_console *pc, bool user_spe= cified) { if (!user_specified) return; @@ -2500,7 +2500,7 @@ static void set_user_specified(struct console_cmdline= *c, bool user_specified) * @c console was defined by the user on the command line. * Do not clear when added twice also by SPCR or the device tree. */ - c->user_specified =3D true; + pc->user_specified =3D true; /* At least one console defined by the user on the command line. */ console_set_on_cmdline =3D 1; } @@ -2509,7 +2509,7 @@ static int __add_preferred_console(const char *name, = const short idx, const char *devname, char *options, char *brl_options, bool user_specified) { - struct console_cmdline *c; + struct preferred_console *pc; int i; =20 if (!name && !devname) @@ -2528,30 +2528,30 @@ static int __add_preferred_console(const char *name= , const short idx, * See if this tty is not yet registered, and * if we have a slot free. */ - for (i =3D 0, c =3D console_cmdline; - i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); - i++, c++) { - if ((name && strcmp(c->name, name) =3D=3D 0 && c->index =3D=3D idx) || - (devname && strcmp(c->devname, devname) =3D=3D 0)) { + for (i =3D 0, pc =3D preferred_consoles; + i < MAX_PREFERRED_CONSOLES && (pc->name[0] || pc->devname[0]); + i++, pc++) { + if ((name && strcmp(pc->name, name) =3D=3D 0 && pc->index =3D=3D idx) || + (devname && strcmp(pc->devname, devname) =3D=3D 0)) { if (!brl_options) preferred_console =3D i; - set_user_specified(c, user_specified); + set_user_specified(pc, user_specified); return 0; } } - if (i =3D=3D MAX_CMDLINECONSOLES) + if (i =3D=3D MAX_PREFERRED_CONSOLES) return -E2BIG; if (!brl_options) preferred_console =3D i; if (name) - strscpy(c->name, name); + strscpy(pc->name, name); if (devname) - strscpy(c->devname, devname); - c->options =3D options; - set_user_specified(c, user_specified); - braille_set_options(c, brl_options); + strscpy(pc->devname, devname); + pc->options =3D options; + set_user_specified(pc, user_specified); + braille_set_options(pc, brl_options); =20 - c->index =3D idx; + pc->index =3D idx; return 0; } =20 @@ -2571,8 +2571,10 @@ __setup("console_msg_format=3D", console_msg_format_= setup); */ static int __init console_setup(char *str) { - static_assert(sizeof(console_cmdline[0].devname) >=3D sizeof(console_cmdl= ine[0].name) + 4); - char buf[sizeof(console_cmdline[0].devname)]; + static_assert(sizeof(preferred_consoles[0].devname) >=3D + sizeof(preferred_consoles[0].name) + 4); + + char buf[sizeof(preferred_consoles[0].devname)]; char *brl_options =3D NULL; char *ttyname =3D NULL; char *devname =3D NULL; @@ -2677,19 +2679,19 @@ int match_devname_and_update_preferred_console(cons= t char *devname, const char *name, const short idx) { - struct console_cmdline *c =3D console_cmdline; + struct preferred_console *pc =3D preferred_consoles; int i; =20 if (!devname || !strlen(devname) || !name || !strlen(name) || idx < 0) return -EINVAL; =20 - for (i =3D 0; i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); - i++, c++) { - if (!strcmp(devname, c->devname)) { + for (i =3D 0; i < MAX_PREFERRED_CONSOLES && (pc->name[0] || pc->devname[0= ]); + i++, pc++) { + if (!strcmp(devname, pc->devname)) { pr_info("associate the preferred console \"%s\" with \"%s%d\"\n", devname, name, idx); - strscpy(c->name, name); - c->index =3D idx; + strscpy(pc->name, name); + pc->index =3D idx; return 0; } } @@ -3859,33 +3861,33 @@ static int console_call_setup(struct console *newco= n, char *options) static int try_enable_preferred_console(struct console *newcon, bool user_specified) { - struct console_cmdline *c; + struct preferred_console *pc; int i, err; =20 - for (i =3D 0, c =3D console_cmdline; - i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); - i++, c++) { + for (i =3D 0, pc =3D preferred_consoles; + i < MAX_PREFERRED_CONSOLES && (pc->name[0] || pc->devname[0]); + i++, pc++) { /* Console not yet initialized? */ - if (!c->name[0]) + if (!pc->name[0]) continue; - if (c->user_specified !=3D user_specified) + if (pc->user_specified !=3D user_specified) continue; if (!newcon->match || - newcon->match(newcon, c->name, c->index, c->options) !=3D 0) { + newcon->match(newcon, pc->name, pc->index, pc->options) !=3D 0) { /* default matching */ - BUILD_BUG_ON(sizeof(c->name) !=3D sizeof(newcon->name)); - if (strcmp(c->name, newcon->name) !=3D 0) + BUILD_BUG_ON(sizeof(pc->name) !=3D sizeof(newcon->name)); + if (strcmp(pc->name, newcon->name) !=3D 0) continue; if (newcon->index >=3D 0 && - newcon->index !=3D c->index) + newcon->index !=3D pc->index) continue; if (newcon->index < 0) - newcon->index =3D c->index; + newcon->index =3D pc->index; =20 - if (_braille_register_console(newcon, c)) + if (_braille_register_console(newcon, pc)) return 0; =20 - err =3D console_call_setup(newcon, c->options); + err =3D console_call_setup(newcon, pc->options); if (err) return err; } @@ -3900,7 +3902,7 @@ static int try_enable_preferred_console(struct consol= e *newcon, * without matching. Accept the pre-enabled consoles only when match() * and setup() had a chance to be called. */ - if (newcon->flags & CON_ENABLED && c->user_specified =3D=3D user_specifie= d) + if (newcon->flags & CON_ENABLED && pc->user_specified =3D=3D user_specifi= ed) return 0; =20 return -ENOENT; --=20 2.52.0 From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 180D12D0618 for ; Fri, 6 Feb 2026 16:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396619; cv=none; b=PlzFKghkaROQxWuJVCVLi8Sky0c4AGwvuBkMAfi0vQBjsTmYT2R8RoZuD2HnGyegizq80Iduh+8APHjLI+xqTR+ls0/nmddhyW64pSPiU8F6taNfTgFgCORUY79lDbYg2MbWo2pjSQquKA1/6aIoVNmHNDxo25oNXLKVYh8ShHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396619; c=relaxed/simple; bh=16M87YMMgnDwGXYTtmn47csCiJDq7ssJmu3wrwwjVr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XnbstDitKaI3ybXaY0ZCT6BlKrIW7zMlWHsxYIsxn1iY1cTtyCHEh0W5lYHcxVMc/65lTdHkFZ1PJm5WoR0/v4FA73XduC9y39CSEnDRBiZ/YYZGPUW66Hi1gqyD/nO9ijrY5G0tCWd/7LErdNlRqzq73Dq/973hMJ5eGPsGCbE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Y1P0dIIo; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Y1P0dIIo; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Y1P0dIIo"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Y1P0dIIo" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id 3A1D53E6E0; Fri, 6 Feb 2026 16:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396617; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QH8USeECcVWaCI8iNAt8Qkkcup8PFWjmSXy18CX47sY=; b=Y1P0dIIoRp2hW7zziFOCal6XhAwWkXcJkeIyu81xSHf2C+KTcHjp2QQeZwbGSOu4G2Ca77 Dms5L0J1oouYACLAgF7i+9MzA85x/kSovSxTeT8QXTXK9uV/lLi0o7P7n4aTfdOTaLd5dA U0NUDkfA0+1BBxWT42LgXWWajP0699U= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=Y1P0dIIo DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396617; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QH8USeECcVWaCI8iNAt8Qkkcup8PFWjmSXy18CX47sY=; b=Y1P0dIIoRp2hW7zziFOCal6XhAwWkXcJkeIyu81xSHf2C+KTcHjp2QQeZwbGSOu4G2Ca77 Dms5L0J1oouYACLAgF7i+9MzA85x/kSovSxTeT8QXTXK9uV/lLi0o7P7n4aTfdOTaLd5dA U0NUDkfA0+1BBxWT42LgXWWajP0699U= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 2/8] printk: Rename preferred_console to preferred_dev_console Date: Fri, 6 Feb 2026 17:49:56 +0100 Message-ID: <20260206165002.496724-3-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[99.99%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[7]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,pathway.suse.cz:helo]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; DNSWL_BLOCKED(0.00)[2a07:de40:b2bf:1b::12bd:from]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Flag: YES X-Spamd-Bar: ++++++++++++++++ X-Rspamd-Queue-Id: 3A1D53E6E0 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: add header X-Spam-Level: **************** X-Spam-Score: 16.67 X-Spam: Yes Content-Type: text/plain; charset="utf-8" The preferred_consoles[] array stores information about consoles requested via the command line, SPCR, Device Tree, or platform-specific code. Within this array, the 'preferred_console' variable tracks the specific index that should be associated with /dev/console (typically the last non-braille console defined). The current name "preferred_console" is ambiguous and leads to confusion. It does not clearly communicate why one console is "more preferred" than others in the array. Furthermore, entries for Braille consoles can exist within the preferred_consoles[] array, yet they are never associated with /dev/console and do not receive standard printk() output. Consequently, the 'preferred_console' index must skip these entries, which is not immediately obvious from the name. Rename the variable to 'preferred_dev_console' to explicitly clarify its role in identifying which entry is linked to /dev/console. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 86a908e74445..3f856a438e74 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -364,7 +364,7 @@ static int console_locked; =20 static struct preferred_console preferred_consoles[MAX_PREFERRED_CONSOLES]; =20 -static int preferred_console =3D -1; +static int preferred_dev_console =3D -1; int console_set_on_cmdline; EXPORT_SYMBOL(console_set_on_cmdline); =20 @@ -2534,7 +2534,7 @@ static int __add_preferred_console(const char *name, = const short idx, if ((name && strcmp(pc->name, name) =3D=3D 0 && pc->index =3D=3D idx) || (devname && strcmp(pc->devname, devname) =3D=3D 0)) { if (!brl_options) - preferred_console =3D i; + preferred_dev_console =3D i; set_user_specified(pc, user_specified); return 0; } @@ -2542,7 +2542,7 @@ static int __add_preferred_console(const char *name, = const short idx, if (i =3D=3D MAX_PREFERRED_CONSOLES) return -E2BIG; if (!brl_options) - preferred_console =3D i; + preferred_dev_console =3D i; if (name) strscpy(pc->name, name); if (devname) @@ -3892,7 +3892,7 @@ static int try_enable_preferred_console(struct consol= e *newcon, return err; } newcon->flags |=3D CON_ENABLED; - if (i =3D=3D preferred_console) + if (i =3D=3D preferred_dev_console) newcon->flags |=3D CON_CONSDEV; return 0; } @@ -4073,7 +4073,7 @@ void register_console(struct console *newcon) * Note that a console with tty binding will have CON_CONSDEV * flag set and will be first in the list. */ - if (preferred_console < 0) { + if (preferred_dev_console < 0) { if (hlist_empty(&console_list) || !console_first()->device || console_first()->flags & CON_BOOT) { try_enable_default_console(newcon); --=20 2.52.0 From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 9ED122DBF47 for ; Fri, 6 Feb 2026 16:50:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396624; cv=none; b=gY3gDmP0jTFo9BpNHNX//zBrjQ+3ntFIZtbBGBO/C00CWuJaA9eGRLz3T7l5XjGqG/LVzk+JipNP2qyRyivFv18E2gb/1rlbWsuSsrPaMtxtxb5HMSLTz3SJ8UmTThnGnnPQdg5uFg4QVw0yf0us8uTk7e16zFdAl//uGpp41Rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396624; c=relaxed/simple; bh=ut88w96/DVfaWRxzklmSBGL7DufjQBHFK177d5GFX1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ps7OENo4fDbi+p4MTvanFQogahLKurpQQ0SA5SY7F7EyODu/NNB80YUbdh1VTC3gTJWv5KQTqctYQ6aRdD4FHZd+mRdZlujE3re7F56Hf7Ohi9ZaBVkfDfA0lIhDDpFkq7aIQck+v7iqQBoxPbiWrEjUaSNTrHYFnHXqrYUkDx8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=enjTDlFG; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=iQiSTh+2; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="enjTDlFG"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="iQiSTh+2" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id B60DA3E6E6; Fri, 6 Feb 2026 16:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396623; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IqmZnGwgIeBsZqyvsIiYTP8E2ig+f3k1b+FAgn3zQfg=; b=enjTDlFGcyLZbQJN1tn6tq3oKyIvPVmE6mkZkOMc4AfNCPRBN2BbRzzhrRR6aBAgUnxoQt dP297np/JRxAXVtaHQph5g76sWwSJD/Nb++njcZpAk6OAWPMKh9TmxLzOl7cJmGL+pUeyy dgAd6Sn3DVzZQYLgp0A2BIEXNqMfmfY= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=iQiSTh+2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396622; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IqmZnGwgIeBsZqyvsIiYTP8E2ig+f3k1b+FAgn3zQfg=; b=iQiSTh+2LmnjRtrr/VrclycO8lJTBY2///ag5L6IndCf2kFijfKdhs9wv8726byk+IBOm1 skqrDpu8RGv5vwUIsy6kAWdp592doDNiVG9ztiHwYDZAN6fWS7nwxEx+hg6NtXg1JBahm9 6ZrVFTmLLhOOsfksFTrqHWcK6OJih4A= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 3/8] printk: Separate code for adding/updating preferred console metadata Date: Fri, 6 Feb 2026 17:49:57 +0100 Message-ID: <20260206165002.496724-4-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[7]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[pathway.suse.cz:helo,suse.com:mid,suse.com:dkim,suse.com:email]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; DNSWL_BLOCKED(0.00)[2a07:de40:b2bf:1b::12bd:from]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Flag: YES X-Spamd-Bar: ++++++++++++++++ X-Rspamd-Queue-Id: B60DA3E6E6 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: add header X-Spam-Level: **************** X-Spam-Score: 16.67 X-Spam: Yes Content-Type: text/plain; charset="utf-8" The logic for adding or updating a preferred console is currently duplicated within __add_preferred_console(), making the code difficult to follow and prone to consistency issues. Introduce update_preferred_console() to centralize the initialization and updating of struct preferred_console entries. This refactoring explicitly defines and enforces the following rules: 1. Console names and/or indexes are not set when a console is preferred via devname; these are resolved later during device matching. 2. Console names are only added alongside a valid index. 3. Only matching entries are updated. 4. Console and Braille options are never cleared. They are updated only via the command line. 5. The global 'preferred_dev_console' index and 'console_set_on_cmdline' flag are updated consistently. Additionally, rename braille_set_options() to braille_update_options() to better reflect its conditional behavior. While this is primarily a refactoring, it fixes two minor behavioral consistencies: console options can now be overridden via the command line, and Braille options are preserved even if a non-Braille console with the same name was previously defined. Signed-off-by: Petr Mladek --- kernel/printk/braille.h | 7 +-- kernel/printk/printk.c | 110 +++++++++++++++++++++++++++------------- 2 files changed, 80 insertions(+), 37 deletions(-) diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h index 55cd3178a17a..0bdac303f8b1 100644 --- a/kernel/printk/braille.h +++ b/kernel/printk/braille.h @@ -5,9 +5,10 @@ #ifdef CONFIG_A11Y_BRAILLE_CONSOLE =20 static inline void -braille_set_options(struct preferred_console *pc, char *brl_options) +braille_update_options(struct preferred_console *pc, char *brl_options) { - pc->brl_options =3D brl_options; + if (brl_options) + pc->brl_options =3D brl_options; } =20 /* @@ -29,7 +30,7 @@ _braille_unregister_console(struct console *console); #else =20 static inline void -braille_set_options(struct preferred_console *pc, char *brl_options) +braille_update_options(struct preferred_console *pc, char *brl_options) { } =20 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 3f856a438e74..ee57c7ac9d02 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2491,18 +2491,82 @@ asmlinkage __visible void early_printk(const char *= fmt, ...) } #endif =20 -static void set_user_specified(struct preferred_console *pc, bool user_spe= cified) +static int update_preferred_console(int i, const char *name, const short i= dx, + const char *devname, char *options, + char *brl_options, bool user_specified) { - if (!user_specified) - return; + struct preferred_console *pc; + + if (i >=3D MAX_PREFERRED_CONSOLES) + return -E2BIG; + + pc =3D &preferred_consoles[i]; + + if (!name && !devname) + return -EINVAL; + + if (devname) { + /* + * A valid console name and index will get assigned when + * a matching device gets registered. + */ + if (name) { + pr_err("Adding a preferred console devname with a hard-coded console na= me: %s, %s\n", + devname, name); + return -EINVAL; + } + if (idx !=3D -1) { + pr_err("Adding a preferred console devname with a hard-coded index: %s,= %d\n", + devname, idx); + return -EINVAL; + } + + if (!pc->devname[0]) { + strscpy(pc->devname, devname); + pc->index =3D idx; + } else if (strcmp(pc->devname, devname) !=3D 0) { + pr_err("Updating a preferred console with an invalid devname: %s vs. %s= \n", + pc->devname, devname); + return -EINVAL; + } + } + + if (name) { + /* A console name must be defined with a valid index. */ + if (idx < 0) { + pr_err("Adding a preferred console with an invalid index: %s, %d\n", + name, idx); + return -EINVAL; + } + + if (!pc->name[0]) { + strscpy(pc->name, name); + pc->index =3D idx; + } else if (strcmp(pc->name, name) !=3D 0 || pc->index !=3D idx) { + pr_err("Updating a preferred console with an invalid name or index: %s%= d vs. %s%d\n", + pc->name, pc->index, name, idx); + return -EINVAL; + } + } + + if (!pc->options || (user_specified && options)) + pc->options =3D options; + + braille_update_options(pc, brl_options); + + if (!brl_options) + preferred_dev_console =3D i; =20 /* * @c console was defined by the user on the command line. * Do not clear when added twice also by SPCR or the device tree. */ - pc->user_specified =3D true; - /* At least one console defined by the user on the command line. */ - console_set_on_cmdline =3D 1; + if (user_specified) { + pc->user_specified =3D true; + console_set_on_cmdline =3D 1; + } + + return 0; } =20 static int __add_preferred_console(const char *name, const short idx, @@ -2515,14 +2579,6 @@ static int __add_preferred_console(const char *name,= const short idx, if (!name && !devname) return -EINVAL; =20 - /* - * We use a signed short index for struct console for device drivers to - * indicate a not yet assigned index or port. However, a negative index - * value is not valid when the console name and index are defined on - * the command line. - */ - if (name && idx < 0) - return -EINVAL; =20 /* * See if this tty is not yet registered, and @@ -2531,28 +2587,14 @@ static int __add_preferred_console(const char *name= , const short idx, for (i =3D 0, pc =3D preferred_consoles; i < MAX_PREFERRED_CONSOLES && (pc->name[0] || pc->devname[0]); i++, pc++) { - if ((name && strcmp(pc->name, name) =3D=3D 0 && pc->index =3D=3D idx) || - (devname && strcmp(pc->devname, devname) =3D=3D 0)) { - if (!brl_options) - preferred_dev_console =3D i; - set_user_specified(pc, user_specified); - return 0; - } + if (name && strcmp(pc->name, name) =3D=3D 0 && pc->index =3D=3D idx) + break; + if (devname && strcmp(pc->devname, devname) =3D=3D 0) + break; } - if (i =3D=3D MAX_PREFERRED_CONSOLES) - return -E2BIG; - if (!brl_options) - preferred_dev_console =3D i; - if (name) - strscpy(pc->name, name); - if (devname) - strscpy(pc->devname, devname); - pc->options =3D options; - set_user_specified(pc, user_specified); - braille_set_options(pc, brl_options); =20 - pc->index =3D idx; - return 0; + return update_preferred_console(i, name, idx, devname, options, + brl_options, user_specified); } =20 static int __init console_msg_format_setup(char *str) --=20 2.52.0 From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 117BF2DAFBD for ; Fri, 6 Feb 2026 16:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396630; cv=none; b=ca3FtHKWl+r6DdDKfif/JKFFW8+I76Uay6apYDN85Q5zj6L6g9M2gD8jwIQaw5+xXLJVwSWHCCmiloAbgMTLL/Q23C5zq+iNqDyp76q6se5HTQy3njHm5VrrGS3ekPqb8Vje2etWnAXASEG9ZKk6sK/dLVcT6Bf+Jxi3v9hVr1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396630; c=relaxed/simple; bh=RulurkoY2+fG7ZD/YGwTONeLkG1iPvev+6OrKIPFiDU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BuaKf1PIcFMfQaMBBMM2TmrRxwA4sISgM0ANpSc2Eq59CuNY1hgSgXcFL8h9xzMNLlUAUoe2GxtlK5rEESidOIekFl/zbFywHTSI4fYUJnQKuUGQNzpC0nbHJRcdmQ3DsOvaW5TI5+cLcVdE1Doq2zSUrnw9NdCelcIrtLJAhwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=cb1fKN6T; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=cb1fKN6T; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="cb1fKN6T"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="cb1fKN6T" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id 429B63E6D4; Fri, 6 Feb 2026 16:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396628; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdJ5qxgh2MlKuSoqiKQorpYRjBnGR+2EPEalbSze0VM=; b=cb1fKN6Thw6v2d0tbCN2BSNmUijNLAkykOzDI/Vf/IZDpHDwLuj7zdwrNar1/yzz8zmfZ2 ONDHqnJ0YOZywOk+fs9+qnbYUbgxuf3T8uyqaIGQui0YT89W5rDTHFd6JOXpiQmeBpjh/m a0ZiglHZyjisqJqd2JD/jEZMCmQEwSg= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=cb1fKN6T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396628; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BdJ5qxgh2MlKuSoqiKQorpYRjBnGR+2EPEalbSze0VM=; b=cb1fKN6Thw6v2d0tbCN2BSNmUijNLAkykOzDI/Vf/IZDpHDwLuj7zdwrNar1/yzz8zmfZ2 ONDHqnJ0YOZywOk+fs9+qnbYUbgxuf3T8uyqaIGQui0YT89W5rDTHFd6JOXpiQmeBpjh/m a0ZiglHZyjisqJqd2JD/jEZMCmQEwSg= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 4/8] printk: Cleanup _braille_(un)register_console() wrappers Date: Fri, 6 Feb 2026 17:49:58 +0100 Message-ID: <20260206165002.496724-5-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[7]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,pathway.suse.cz:helo]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; DNSWL_BLOCKED(0.00)[2a07:de40:b2bf:1b::12bd:from]; DKIM_TRACE(0.00)[suse.com:+] X-Spam-Flag: YES X-Spamd-Bar: ++++++++++++++++ X-Rspamd-Queue-Id: 429B63E6D4 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: add header X-Spam-Level: **************** X-Spam-Score: 16.67 X-Spam: Yes Content-Type: text/plain; charset="utf-8" The _braille_(un)register_console() wrappers currently attempt to hide implementation details like the CON_BRL flag and pc->brl_options. This forces callers to handle an unconventional tri-state return value (0 for NOP, >0 for success, <0 for error), which makes the control flow harder to follow and non-standard. Refactor the wrappers to use standard kernel return codes (0 for success, -ERRCODE on failure). Move the responsibility of checking brl_options to the caller to make the logic more explicit. Additionally, move the assignment of the CON_BRL flag from the internal wrapper to braille_register_console(). This aligns it with how CON_ENABLED is handled. To maintain symmetry and fix a potential bug where flags might persist after removal, explicitly clear both CON_ENABLED and CON_BRL in braille_unregister_console(). Signed-off-by: Petr Mladek --- drivers/accessibility/braille/braille_console.c | 7 ++++--- kernel/printk/braille.c | 16 +++------------- kernel/printk/braille.h | 12 ++++++++++++ kernel/printk/printk.c | 13 +++++-------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/acce= ssibility/braille/braille_console.c index 06b43b678d6e..7b324329882f 100644 --- a/drivers/accessibility/braille/braille_console.c +++ b/drivers/accessibility/braille/braille_console.c @@ -360,12 +360,12 @@ int braille_register_console(struct console *console,= int index, if (ret !=3D 0) return ret; } - console->flags |=3D CON_ENABLED; + console->flags |=3D CON_ENABLED | CON_BRL; console->index =3D index; braille_co =3D console; register_keyboard_notifier(&keyboard_notifier_block); register_vt_notifier(&vt_notifier_block); - return 1; + return 0; } =20 int braille_unregister_console(struct console *console) @@ -375,5 +375,6 @@ int braille_unregister_console(struct console *console) unregister_keyboard_notifier(&keyboard_notifier_block); unregister_vt_notifier(&vt_notifier_block); braille_co =3D NULL; - return 1; + console->flags &=3D ~(CON_ENABLED | CON_BRL); + return 0; } diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c index 9d21a2bb1d38..593f83eb0487 100644 --- a/kernel/printk/braille.c +++ b/kernel/printk/braille.c @@ -37,22 +37,12 @@ int _braille_console_setup(char **str, char **brl_optio= ns) int _braille_register_console(struct console *console, struct preferred_consol= e *pc) { - int rtn =3D 0; - - if (pc->brl_options) { - console->flags |=3D CON_BRL; - rtn =3D braille_register_console(console, pc->index, pc->options, - pc->brl_options); - } - - return rtn; + return braille_register_console(console, pc->index, pc->options, + pc->brl_options); } =20 int _braille_unregister_console(struct console *console) { - if (console->flags & CON_BRL) - return braille_unregister_console(console); - - return 0; + return braille_unregister_console(console); } diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h index 0bdac303f8b1..ec5feac1f508 100644 --- a/kernel/printk/braille.h +++ b/kernel/printk/braille.h @@ -11,6 +11,12 @@ braille_update_options(struct preferred_console *pc, cha= r *brl_options) pc->brl_options =3D brl_options; } =20 +static inline bool +is_braille_console_preferred(struct preferred_console *pc) +{ + return (!!pc->brl_options); +} + /* * Setup console according to braille options. * Return -EINVAL on syntax error, 0 on success (or no braille option was @@ -34,6 +40,12 @@ braille_update_options(struct preferred_console *pc, cha= r *brl_options) { } =20 +static inline bool +is_braille_console_preferred(struct preferred_console *pc) +{ + return false; +} + static inline int _braille_console_setup(char **str, char **brl_options) { diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ee57c7ac9d02..4b2865831a62 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3926,8 +3926,8 @@ static int try_enable_preferred_console(struct consol= e *newcon, if (newcon->index < 0) newcon->index =3D pc->index; =20 - if (_braille_register_console(newcon, pc)) - return 0; + if (is_braille_console_preferred(pc)) + return _braille_register_console(newcon, pc); =20 err =3D console_call_setup(newcon, pc->options); if (err) @@ -4239,17 +4239,14 @@ static int unregister_console_locked(struct console= *console) bool found_boot_con =3D false; unsigned long flags; struct console *c; - int res; + int res =3D 0; =20 lockdep_assert_console_list_lock_held(); =20 con_printk(KERN_INFO, console, "disabled\n"); =20 - res =3D _braille_unregister_console(console); - if (res < 0) - return res; - if (res > 0) - return 0; + if (console->flags & CON_BRL) + return _braille_unregister_console(console); =20 if (!console_is_registered_locked(console)) res =3D -ENODEV; --=20 2.52.0 From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 60FAC2DC765 for ; Fri, 6 Feb 2026 16:50:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396635; cv=none; b=Vf1ohktzys4tiJRisybLQL7MT5KME6skXiNSEHmN2cPDAGDIJ9+6SKO70dCMJ0+o5SflWz1MxSE6Pa6qxihzOopX9L61EXYf+yIyNrp7Ewl0iFgKt3kolCXgRjS5EfH+B8D88me3ZnjkKQi67LpIXbgWM/i+v+HszrmdwofR/4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396635; c=relaxed/simple; bh=/z5oLpM69iaqyxIg6fwqY7Sfpfl9Xx2jBq7E/j6ElcQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sDh23RtIHMw4f2RCfCCXappM5xqOkaGHHeSY0DBE7eB8gMPIPaeg22RmLtlv7E2SBhhlBz4mV+WUwYVliBHwFOYJNUw7PM8t0NgXtgW5JwspAURjH20O82GJBBCONdXNWEIo93bXFgDVnJiy748V8O4CR3guThS4hjOmZHRWRQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=KijH+X/H; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=KijH+X/H; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="KijH+X/H"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="KijH+X/H" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id 9239D3E6D1; Fri, 6 Feb 2026 16:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396633; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pXBz24PwjdfFY7YSepgUit3CJ5sw/1zHtZmuS3TqCAk=; b=KijH+X/HmKIwlHcYp693yQ0qamJImKZZJ9kcLwWQFIy0kyuNV7wm+xHlAp9T2DfvUH/y01 QmWYMaLbyq9rKO1iUUrMe8MTfh/RohsHfydZ2tAdV9/llWAxig6KfzjFau0dkv1hxyVaQ0 GDnEUHieAUL5/8NhH02H2vg+3mpuIOI= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b="KijH+X/H" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396633; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pXBz24PwjdfFY7YSepgUit3CJ5sw/1zHtZmuS3TqCAk=; b=KijH+X/HmKIwlHcYp693yQ0qamJImKZZJ9kcLwWQFIy0kyuNV7wm+xHlAp9T2DfvUH/y01 QmWYMaLbyq9rKO1iUUrMe8MTfh/RohsHfydZ2tAdV9/llWAxig6KfzjFau0dkv1hxyVaQ0 GDnEUHieAUL5/8NhH02H2vg+3mpuIOI= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 5/8] printk: Try to register each console as Braille first Date: Fri, 6 Feb 2026 17:49:59 +0100 Message-ID: <20260206165002.496724-6-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [16.18 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_SHORT(2.99)[0.996]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; MID_CONTAINS_FROM(1.00)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLgy8oz5x7j7it6a73zx4uugbi)]; RCVD_COUNT_ZERO(0.00)[0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; DNSWL_BLOCKED(0.00)[2a07:de40:b2bf:1b::12bd:from]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[pathway.suse.cz:helo,suse.com:mid,suse.com:dkim,suse.com:email] X-Spam-Flag: YES X-Spamd-Bar: ++++++++++++++++ X-Rspamd-Queue-Id: 9239D3E6D1 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: add header X-Spam-Level: **************** X-Spam-Score: 16.18 X-Spam: Yes Braille consoles are unique: they can only be enabled via the command line and use the preferred console framework for initialization, yet they are never added to the console_list or associated with /dev/console. Because of this, the preferred_console variable remains unset when only a Braille console is requested. Currently, try_enable_preferred_console() must be called even when "preferred_dev_console" variable is not set, just to catch these "hidden" Braille requests. The logic relies on non-obvious shortcuts within both try_enable_preferred_console() and register_console(), making the initialization flow fragile and difficult to follow. Refactor the logic by adding a parameter to try_enable_preferred_console() to explicitly handle Braille vs. non-Braille cases. This removes the need for implicit shortcuts in register_console(). It will eventually allow to skip try_enable_preferred_console() when there are no preferred consoles. This improves code robustness by ensuring the console setup is explicit and only performed once. The refactoring even fixes two subtle bugs: 1. When only the Braille console is defined on the command line, the original code might attempt to enable the same console twice=E2=80= =94once as a default and once as a Braille console. This results in calling the setup() callback twice and incorrectly setting the CON_CONSDEV flag. 2. When the same console is defined on the command line using devname and then as Braille console, for example: console=3D00:00:0.0,115200 console=3Dbrl,ttyS0,115200 It would have two separate entries in preferred_consoles[] array. The 2nd (Braille) entry would be used when univ8250_console_init() tries to register the generic "ttyS" console driver. Note that the 1st entry still does not have defined the "name" entry at this stage. The 1st non-Braille entry would be used later when serial8250_init() registers all found devices, assigns "tty0" for the given "00:00:0.0" devname and tries to register the same struct console once again. The original code would call newcon->setup() twice in this scenario. It won't add the console into console_list only because the later check in register_console() would detect CON_BRL flag set from the 1st registration and return early. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 56 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 4b2865831a62..279b36ef90bd 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -365,6 +365,7 @@ static int console_locked; static struct preferred_console preferred_consoles[MAX_PREFERRED_CONSOLES]; =20 static int preferred_dev_console =3D -1; +static bool want_braille_console; int console_set_on_cmdline; EXPORT_SYMBOL(console_set_on_cmdline); =20 @@ -2554,7 +2555,9 @@ static int update_preferred_console(int i, const char= *name, const short idx, =20 braille_update_options(pc, brl_options); =20 - if (!brl_options) + if (brl_options) + want_braille_console =3D true; + else preferred_dev_console =3D i; =20 /* @@ -3900,8 +3903,9 @@ static int console_call_setup(struct console *newcon,= char *options) * Care need to be taken with consoles that are statically * enabled such as netconsole */ -static int try_enable_preferred_console(struct console *newcon, - bool user_specified) +static int __try_enable_preferred_console(struct console *newcon, + bool user_specified, + bool try_only_braille) { struct preferred_console *pc; int i, err; @@ -3918,6 +3922,12 @@ static int try_enable_preferred_console(struct conso= le *newcon, newcon->match(newcon, pc->name, pc->index, pc->options) !=3D 0) { /* default matching */ BUILD_BUG_ON(sizeof(pc->name) !=3D sizeof(newcon->name)); + /* + * Two entries might have the same pc->name when one was + * defined via "devname". + */ + if (try_only_braille && !is_braille_console_preferred(pc)) + continue; if (strcmp(pc->name, newcon->name) !=3D 0) continue; if (newcon->index >=3D 0 && @@ -3926,7 +3936,7 @@ static int try_enable_preferred_console(struct consol= e *newcon, if (newcon->index < 0) newcon->index =3D pc->index; =20 - if (is_braille_console_preferred(pc)) + if (try_only_braille) return _braille_register_console(newcon, pc); =20 err =3D console_call_setup(newcon, pc->options); @@ -3950,6 +3960,17 @@ static int try_enable_preferred_console(struct conso= le *newcon, return -ENOENT; } =20 +static int try_enable_preferred_console(struct console *newcon, + bool user_specified) +{ + return __try_enable_preferred_console(newcon, user_specified, false); +} + +static int try_enable_braille_console(struct console *newcon) +{ + return __try_enable_preferred_console(newcon, true, true); +} + /* Try to enable the console unconditionally */ static void try_enable_default_console(struct console *newcon) { @@ -4103,6 +4124,20 @@ void register_console(struct console *newcon) goto unlock; } =20 + /* + * First, try to enable the console driver as a Braille console. + * It would have metadata in the preferred_consoles[] array. + * But it won't be counted as @preferred_console because + * it does not get printk() messages and is not associated + * with /dev/console. + */ + if (want_braille_console) { + err =3D try_enable_braille_console(newcon); + /* Return on success or when con->setup failed. */ + if (err !=3D -ENOENT) + goto unlock_free; + } + /* * See if we want to enable this console driver by default. * @@ -4129,12 +4164,8 @@ void register_console(struct console *newcon) if (err =3D=3D -ENOENT) err =3D try_enable_preferred_console(newcon, false); =20 - /* printk() messages are not printed to the Braille console. */ - if (err || newcon->flags & CON_BRL) { - if (newcon->flags & CON_NBCON) - nbcon_free(newcon); - goto unlock; - } + if (err) + goto unlock_free; =20 /* * If we have a bootconsole, and are switching to a real console, @@ -4227,6 +4258,11 @@ void register_console(struct console *newcon) printk_kthreads_check_locked(); unlock: console_list_unlock(); + return; + +unlock_free: + nbcon_free(newcon); + goto unlock; } EXPORT_SYMBOL(register_console); =20 --=20 2.52.0 From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 B767C2DC765 for ; Fri, 6 Feb 2026 16:50:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396641; cv=none; b=O21HixOQAimY6LeP+u7Xgzc6ssVDGCqzfK4I4lrO/aYNfulnUXVpg2Hk/xHmu06jXmJO/80t7bZ1T0U+c0f73ix1gznMgflRUO0WIU2e0oFTFBfF7Ek7bhAbEZsJnrDZw6RfgRf7zVP0SUAwHcL7T4XgZwUhuYWQlIqU7ZNP1Bs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396641; c=relaxed/simple; bh=FLIAj97IJtWec5FxAAqgkF94UP7fJT2sYRy9Rv0J8TM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fGwfgQKHhU6Jc+YGwF2KHFN2qBO/ZfhXxooU2XqDY4OpjfN36JvWHZ+ER0NHqU5D7h1mxdcE+4MnwgVYiY7hfVXhKKhD2NuNS0WwtvPkfSEUl89vaXvprpJ6xPcUEPpu1LKcwry9F9anrO6cHublhJ5KypylF2NDua+J8PWdZZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=o57yazte; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=o57yazte; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="o57yazte"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="o57yazte" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id 1AF203E6D4; Fri, 6 Feb 2026 16:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396639; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FdgcmSxPAwUXwZhrQwTcWv3u5B8erPdoTHSxithi8Ug=; b=o57yazteeqQjv4/zryPsdPgpvrL2rEDgdCKgFR+1PKrHLy/b+qMJU3Aqc5L0ZogqXaQQr7 f/9qBKmyRvCOKhqg8bPkcUKORXQOcpjvJwpUorjiUX2gVtcW3cU5cHe8oDdbirQwZxSySZ SF7+IEjhtkYYOWsc6ylYatzqyY9AqYE= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=o57yazte DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396639; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FdgcmSxPAwUXwZhrQwTcWv3u5B8erPdoTHSxithi8Ug=; b=o57yazteeqQjv4/zryPsdPgpvrL2rEDgdCKgFR+1PKrHLy/b+qMJU3Aqc5L0ZogqXaQQr7 f/9qBKmyRvCOKhqg8bPkcUKORXQOcpjvJwpUorjiUX2gVtcW3cU5cHe8oDdbirQwZxSySZ SF7+IEjhtkYYOWsc6ylYatzqyY9AqYE= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 6/8] printk: Do not set Braille console as preferred_console Date: Fri, 6 Feb 2026 17:50:00 +0100 Message-ID: <20260206165002.496724-7-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 16.67 X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[99.99%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,pathway.suse.cz:helo]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLgy8oz5x7j7it6a73zx4uugbi)]; DKIM_TRACE(0.00)[suse.com:+]; RCPT_COUNT_SEVEN(0.00)[7] X-Rspamd-Action: add header X-Rspamd-Queue-Id: 1AF203E6D4 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: **************** X-Spamd-Bar: ++++++++++++++++ X-Spam-Flag: YES X-Spam: Yes Content-Type: text/plain; charset="utf-8" The Braille console reuses the framework for handling consoles preferred via the command line. However, it is a special-purpose interface that neither receives standard printk messages nor associates with /dev/console. Currently, the "preferred_dev_console" variable can point to a Braille console entry in the "preferred_consoles[]" array. This occurs if an entry was first created for a non-Braille console, but a later 'console=3D' parameter redefined it as a Braille console. Since a Braille console will only ever be enabled as such, it should not be tracked as the primary system console. Adjust the logic to ensure "preferred_dev_console" continues to point to the previously designated normal console instead. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 279b36ef90bd..eb224eaace64 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -365,6 +365,7 @@ static int console_locked; static struct preferred_console preferred_consoles[MAX_PREFERRED_CONSOLES]; =20 static int preferred_dev_console =3D -1; +static int preferred_dev_console_prev =3D -1; static bool want_braille_console; int console_set_on_cmdline; EXPORT_SYMBOL(console_set_on_cmdline); @@ -2555,10 +2556,23 @@ static int update_preferred_console(int i, const ch= ar *name, const short idx, =20 braille_update_options(pc, brl_options); =20 - if (brl_options) + if (brl_options) { want_braille_console =3D true; - else + /* + * This console name will always get enabled as Braille + * console. It takes special code paths in register_console(). + * Do not treat it as a normal preferred_console. + */ + if (preferred_dev_console =3D=3D i) + preferred_dev_console =3D preferred_dev_console_prev; + } else { + /* + * Only the VisioBraille device is supported at the moment. + * One level history should be enough. + */ + preferred_dev_console_prev =3D preferred_dev_console; preferred_dev_console =3D i; + } =20 /* * @c console was defined by the user on the command line. --=20 2.52.0 From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 434522DAFBD for ; Fri, 6 Feb 2026 16:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396646; cv=none; b=bQ6fywDYb/ZohoTQmnFu4gb87FkFKep6lzAZmlwacM/7QNh9ch0vICC1FJRLzW18L7qMh10XY5thYJqUZlVGEsvOuR9Lu19FhDRDnuuvRK3gbuGjB4h9YPxKyDC4+XiqTXnD9Sj7fIyOQ4kD/3vV7kRKDwqFt1tSPA1CjsGKr74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396646; c=relaxed/simple; bh=p6b0pYVV8naHmIggxWi1jtulo49jTimZbmMBRKZgDdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S5GCUPlKc3ZMumCs/P2vAVoLXn8TwNZWGZ5zVTsu43nELk47Wy2Pr5cSSX577LymEngYu666yLPjQnLzOBbyhoXZdMnwNXGOe4BsUc8cSlzJAq4V1VfUTBr9w5JEFpzq+znUekPngXbdBfehm37tJ/9voGO4EgVY57jw33IiLtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=agJV4Dhm; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=agJV4Dhm; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="agJV4Dhm"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="agJV4Dhm" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id 704473E6D1; Fri, 6 Feb 2026 16:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396644; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dxw47kxMhMVDr/xDNlT8DbsgBhrYS6i+o0FBGaNAC+w=; b=agJV4DhmBQMP2OWQCdqcPgi17iv3O52F6Q0LSx42ij9y5w2wNsFoRrdd0g9kLpsigjkvvK qq1tMsgNF5UpxaLWlzonrBJFYLuKiJIxO5/w2h4/1Lsu61yultM1fSN9t961y6fcPI3KjI WHHPqDgQ4CoYSvK0HbOq496cJ4LtWq4= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=agJV4Dhm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396644; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dxw47kxMhMVDr/xDNlT8DbsgBhrYS6i+o0FBGaNAC+w=; b=agJV4DhmBQMP2OWQCdqcPgi17iv3O52F6Q0LSx42ij9y5w2wNsFoRrdd0g9kLpsigjkvvK qq1tMsgNF5UpxaLWlzonrBJFYLuKiJIxO5/w2h4/1Lsu61yultM1fSN9t961y6fcPI3KjI WHHPqDgQ4CoYSvK0HbOq496cJ4LtWq4= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 7/8] printk: Handle pre-enabled consoles directly in register_console() Date: Fri, 6 Feb 2026 17:50:01 +0100 Message-ID: <20260206165002.496724-8-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 16.67 X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,pathway.suse.cz:helo]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLgy8oz5x7j7it6a73zx4uugbi)]; DKIM_TRACE(0.00)[suse.com:+]; RCPT_COUNT_SEVEN(0.00)[7] X-Rspamd-Action: add header X-Rspamd-Queue-Id: 704473E6D1 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: **************** X-Spamd-Bar: ++++++++++++++++ X-Spam-Flag: YES X-Spam: Yes Content-Type: text/plain; charset="utf-8" The function try_enable_preferred_console() currently has the non-obvious side effect of returning success for consoles that are already pre-enabled. This obscures the logic flow during console registration. Move the check for pre-enabled consoles directly into register_console(). This change makes the handling of pre-enabled consoles explicit and easier to follow. Furthermore, this separation lays the groundwork for future cleanups where try_enable_preferred_console() can be restricted to cases where an entry actually exists in the preferred_consoles[] array. Possible behavior change: try_enable_preferred_console() will newly be called also with @user_specified parameter set to "false" when it failed with the "true" variant. But it looks like the right way to do. It will allow to call newcon->setup() when the console was preferred by some platform specific code. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index eb224eaace64..db91be780de9 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3913,9 +3913,6 @@ static int console_call_setup(struct console *newcon,= char *options) * the newly registered console with any of the ones selected * by either the command line or add_preferred_console() and * setup/enable it. - * - * Care need to be taken with consoles that are statically - * enabled such as netconsole */ static int __try_enable_preferred_console(struct console *newcon, bool user_specified, @@ -3963,14 +3960,6 @@ static int __try_enable_preferred_console(struct con= sole *newcon, return 0; } =20 - /* - * Some consoles, such as pstore and netconsole, can be enabled even - * without matching. Accept the pre-enabled consoles only when match() - * and setup() had a chance to be called. - */ - if (newcon->flags & CON_ENABLED && pc->user_specified =3D=3D user_specifi= ed) - return 0; - return -ENOENT; } =20 @@ -4178,6 +4167,14 @@ void register_console(struct console *newcon) if (err =3D=3D -ENOENT) err =3D try_enable_preferred_console(newcon, false); =20 + /* + * Some consoles, such as pstore and netconsole, can be enabled even + * without matching. Accept them at this stage when they had a chance + * to match() and call setup(). + */ + if (err =3D=3D -ENOENT && (newcon->flags & CON_ENABLED)) + err =3D 0; + if (err) goto unlock_free; =20 --=20 2.52.0 From nobody Sat Feb 7 11:38:46 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 990862DAFBD for ; Fri, 6 Feb 2026 16:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396651; cv=none; b=nL14j9bqYH+u7qC2YGUnWZANKGPWI1xykZK0rcQLxbjXKpg93cN+zKiJd1A071xrw3eny17RRMxK2wVbvSWkxp3bpIuonuIsYA9BLPPW7fuAg14hFGEmiYDKFjIZrxalnOGnAYiPshquC/G6grzIgQAFUv35U2FCY8ccTWA+QtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770396651; c=relaxed/simple; bh=wpgCvfOgdITndxyepidQ/JlosG0zeif2yaNC0hxESug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EypjJHHtIaMFN+IoDIrVFcKHNTN2Tv2JN+55h7a06VEYdvX7LuFH++BYAYXu8PqIQohTXHDLNnNJ+WSVwD8Tcq20h/7jq7P/2EfxVnoOxO/i6HB16J9TeY6jmht/pbRrNDZisnEifPQW7COOftcS61Ev9Q2b0SlHOl8dRjyvmPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=q5r6ywUO; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=q5r6ywUO; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="q5r6ywUO"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="q5r6ywUO" Received: from pathway.suse.cz (unknown [IPv6:2a07:de40:b2bf:1b::12bd]) by smtp-out1.suse.de (Postfix) with ESMTP id E94EB3E6D1; Fri, 6 Feb 2026 16:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396650; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nzP1D8W3d7pjkl0kcoS4Zteyfrkagaaz4P5quhuBwQ0=; b=q5r6ywUOd9lpDzQEfUlaPHIoeKVjzo+ohnVEdVJLHHF+XugL6gXdTE4D6tCa3DZBG41lMY Bm2ixXiPfquknrO1sSTTYJsELgdw2dGxYy6/9xbEi+0uC8R2kQ8kApBdCnX+2BzmzQwzEj 8QTdfHDFOX6JFTaQWCoSUGIeS8kWGXg= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=q5r6ywUO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770396650; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nzP1D8W3d7pjkl0kcoS4Zteyfrkagaaz4P5quhuBwQ0=; b=q5r6ywUOd9lpDzQEfUlaPHIoeKVjzo+ohnVEdVJLHHF+XugL6gXdTE4D6tCa3DZBG41lMY Bm2ixXiPfquknrO1sSTTYJsELgdw2dGxYy6/9xbEi+0uC8R2kQ8kApBdCnX+2BzmzQwzEj 8QTdfHDFOX6JFTaQWCoSUGIeS8kWGXg= From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH 8/8] printk: Try enable preferred consoles only when there are any Date: Fri, 6 Feb 2026 17:50:02 +0100 Message-ID: <20260206165002.496724-9-pmladek@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260206165002.496724-1-pmladek@suse.com> References: <20260206165002.496724-1-pmladek@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [16.67 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; NEURAL_SPAM_SHORT(2.98)[0.994]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[pathway.suse.cz]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; HFILTER_HELO_NORES_A_OR_MX(0.30)[pathway.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:dkim,suse.com:email,pathway.suse.cz:helo]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[7]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b2bf:1b::12bd:from]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; DIRECT_TO_MX(0.00)[git-send-email 2.52.0]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; SPAMHAUS_XBL(0.00)[2a07:de40:b2bf:1b::12bd:from]; R_RATELIMIT(0.00)[to_ip_from(RLgy8oz5x7j7it6a73zx4uugbi)]; DKIM_TRACE(0.00)[suse.com:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; DNSWL_BLOCKED(0.00)[2a07:de40:b2bf:1b::12bd:from]; TO_MATCH_ENVRCPT_ALL(0.00)[] X-Spam-Flag: YES X-Spamd-Bar: ++++++++++++++++ X-Rspamd-Queue-Id: E94EB3E6D1 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: add header X-Spam-Level: **************** X-Spam-Score: 16.67 X-Spam: Yes Content-Type: text/plain; charset="utf-8" try_enable_preferred_console() used to be always called because it had several hidden effects, namely: - enabled Braille consoles which were ignored by "preferred_dev_console" because they were not associated with /dev/console. - returned success when a console was pre-enabled using CON_ENABLED flag. - returned success when a console was enabled by default because try_enable_default_console() did not return success. The first two hidden effects were removed in previous patches. Remove the last one so that try_enable_preferred_console() can be called only when any non-Braille console is preferred. Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index db91be780de9..462d870feaf2 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3975,18 +3975,23 @@ static int try_enable_braille_console(struct consol= e *newcon) } =20 /* Try to enable the console unconditionally */ -static void try_enable_default_console(struct console *newcon) +static int try_enable_default_console(struct console *newcon) { + int err; + if (newcon->index < 0) newcon->index =3D 0; =20 - if (console_call_setup(newcon, NULL) !=3D 0) - return; + err =3D console_call_setup(newcon, NULL); + if (err) + return err; =20 newcon->flags |=3D CON_ENABLED; =20 if (newcon->device) newcon->flags |=3D CON_CONSDEV; + + return 0; } =20 /* Return the starting sequence number for a newly registered console. */ @@ -4156,17 +4161,15 @@ void register_console(struct console *newcon) if (preferred_dev_console < 0) { if (hlist_empty(&console_list) || !console_first()->device || console_first()->flags & CON_BOOT) { - try_enable_default_console(newcon); + err =3D try_enable_default_console(newcon); } + } else { + err =3D try_enable_preferred_console(newcon, true); + + if (err =3D=3D -ENOENT) + err =3D try_enable_preferred_console(newcon, false); } =20 - /* See if this console matches one we selected on the command line */ - err =3D try_enable_preferred_console(newcon, true); - - /* If not, try to match against the platform default(s) */ - if (err =3D=3D -ENOENT) - err =3D try_enable_preferred_console(newcon, false); - /* * Some consoles, such as pstore and netconsole, can be enabled even * without matching. Accept them at this stage when they had a chance --=20 2.52.0