From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 311962F693B for ; Thu, 4 Jun 2026 10:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780568220; cv=none; b=HmRTNhw/2ZR1WmCYHpNAwyZTUV3zvr+6A1yreaM4vCbFOyRyewvmRKUziMBtzKX1JkWkrI+Men637GCQxzau85hptnKIHkcelx59lHBX4oVmFT+BOcDWfj3+u+M4o/nMNpkXrWzABGgGZFT16NgfgbgR5LtnGRAGWaM+wD20VyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780568220; c=relaxed/simple; bh=VCsLyFxHscTUS9oWvKhuTa5oEdz2tMyHJsu0SzPLGuo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b9MZ827rAWIgt9oVxFeBUNn2VWfQpXdpts3cD+gZFcZG7+qa2VByRbHBMmBP7eiG8lI6wZCgq+g3kMGT31+1fOxF+uJc1ZYpxx/9lZe1ziy5QJyNg3BObozwWaIojbt53OWcryx7KjXHaPr09HKsKd4lU0ox1/aJKAvHC+Q6YgQ= 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 (2048-bit key) header.d=suse.com header.i=@suse.com header.b=YIYgnXCo; arc=none smtp.client-ip=209.85.128.43 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 (2048-bit key) header.d=suse.com header.i=@suse.com header.b="YIYgnXCo" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-490b3637b90so4739005e9.3 for ; Thu, 04 Jun 2026 03:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1780568218; x=1781173018; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fybwUUcgvAmcpQ3ZjDoHTmIuRtRDI1Lr+X8F/Nj3OTs=; b=YIYgnXCotYZJafwvyTRP8DLAalp47E2+DSmgONcMGnHiG0AkyE/tI5RUXMEquf2Cwb 8ryzWZS133H3+hZFBAo7cK51GPWHRCkH0ATbaMd56j65xXpxCZ2TQWs+WthQrWvxirxe VytnOcyDjwt35KXLLLqeOx5aJfJL0Sx139y3JSLJNJb0e57ojXag+9PbyA300pxSy4BL tv9vU+apRwP+5HDnxmuSNIVNwDsIua7xLbZh8kMwPVZbkvV3KmNEUO1EpqO958DRd9ag dIZb+39iT0zzATfa8l1Uxuav3k0pdLvOZyMPAF++J1Ai6+vAWvBXhqbLpPDmXU8OF2JV vRqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780568218; x=1781173018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fybwUUcgvAmcpQ3ZjDoHTmIuRtRDI1Lr+X8F/Nj3OTs=; b=L2e8VxWrUY21YaVtFKGKw3lu8IT9Yl9ysrxwO+Qv0I2CDr85Zk0I/JuOEiw2f7MQJV uNgkFRhs2xNF68COR1zqr2mu4ijClEAu/henv2r38dGSEckYx5UDjMjb9FHySwOPjIg+ JoS1Gz38pvYLBzaWEBz6c+lpwnqxoq1E49P3OTzA/2Q0ajuOhezDaJHyMhAPUDDHzq4+ m36R/WkblqoH3q0UOh4wcjW3Zmg0wt4/IvWAGn1/1m5ubXE/R/8H1O+3sH8+twPs0PZo B8jz//9nRrNHI+KH+ijrk8o/XasM4chB0EK/yC5Kyenb19omt8OpLwu6jMBV53D3MRIW zWpw== X-Forwarded-Encrypted: i=1; AFNElJ/MsqxnR+GPZJO7158JFAFtHnvuGXkGujs/ZvNxOCuRHO4hHV5HVUFH2fKHaaOw3VdmBhOiwwA/skJhNWM=@vger.kernel.org X-Gm-Message-State: AOJu0YyxWoRixyzym78RJNSXUgcl364URikIaeJJ0Nre2puSlymK6AV1 yK9xkTc3imhF6QaKzR61fPLP7JRGy9kYJW57bC7n9fJDxxHt8eCkiQMWC+XfH1s5fDI= X-Gm-Gg: Acq92OFUKHPO749AOtDTOrq+zlGYyjVJhLC92eDPPNmqirbQEHl1x7t0PXgiHJgXm5x KNd2H6FLYeUrGyg6lDPxA4mudtoTDC/B6eykJ9z5YwOwz8Lk96oEMhK3gQjhsBPlGX8ozw76pIC 2WsEeud0MpDoYmLVtArwMjaaVNagAsIdZkppD9a3b4YIrjXCOWfsstWD+1rcLL7tE+U3P/VCQKi kl05CPu5ST4b+CesM4aO1Cz/kxC+yi+wKTjPZV7TgTwkEGPMSo+PPYkg33ru81wTIrYeK0rVYav F0ZkS4vPLik/axohlyYlx4da+6jpw17zLzmUMmveHXec5qWBXoJDFxkXnkuEy/I3hdT58n9rtaw OcgCtcBwknZG4RYPYfLQ8pEwPqyntdfHGh3NrJbkOp5lo6UicC+GPr6IcGWFen2grbxBCeuQHen KsRfFnEcFyDXRdtxF7bxYtFNMwjD+FEod4polP X-Received: by 2002:a05:600c:a09:b0:490:958f:2a5c with SMTP id 5b1f17b1804b1-490b5ed6375mr120898895e9.17.1780568217220; Thu, 04 Jun 2026 03:16:57 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc39e024sm73701835e9.4.2026.06.04.03.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 03:16:56 -0700 (PDT) From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , Naveen Kumar Chaudhary , linux-kernel@vger.kernel.org, Petr Mladek Subject: [PATCH v4 09/11] printk: Do not set Braille console as preferred_console Date: Thu, 4 Jun 2026 12:14:56 +0200 Message-ID: <20260604101459.393162-10-pmladek@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604101459.393162-1-pmladek@suse.com> References: <20260604101459.393162-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: 8bit 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=' 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 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 3a645558c18a..a4eaf157cece 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -367,6 +367,7 @@ static int console_locked; static struct preferred_console preferred_consoles[MAX_PREFERRED_CONSOLES]; static int preferred_dev_console = -1; +static int preferred_dev_console_prev = -1; static bool want_braille_console; int console_set_on_cmdline; EXPORT_SYMBOL(console_set_on_cmdline); @@ -2566,10 +2567,11 @@ asmlinkage __visible void early_printk(const char *fmt, ...) * Note that a valid @name and @idx will get assigned later when * @devname matches during the device initialization. * 2. Specify @brl_options if the console should be enabled as - * a Braille console [*] + * a Braille console. * 3. Only matching entries can be updated. * 4. @options passed via the command line are used when the same * console is preferred also by some platform-specific code. + * 5. Braille console is never associated with /dev/console.[*] * * [*] Braille console is using the mechanism for registering consoles * but it is very special. It is primarily used for user interaction @@ -2649,10 +2651,22 @@ static int add_or_update_preferred_console(unsigned int i, braille_update_options(pc, brl_options); - if (brl_options) + /* + * The last preferred console should get associated with /dev/console. + * Except for the Braille console which can't get associated with + * /dev/console. One level history should be enough because only one, + * the VisioBraille device, is supported at the moment. + */ + if (brl_options) { want_braille_console = true; - else + if (preferred_dev_console == i) { + preferred_dev_console = preferred_dev_console_prev; + preferred_dev_console_prev = -1; + } + } else if (!is_braille_console_preferred(pc)) { + preferred_dev_console_prev = preferred_dev_console; preferred_dev_console = i; + } /* * @pc console was defined by the user on the command line. -- 2.54.0