From nobody Sat Feb 7 13:45:26 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