From nobody Sun Feb 8 18:49:27 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