Message ID | 20221114162932.141883-23-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2238536wru; Mon, 14 Nov 2022 08:32:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf40GF+ybKxj7W80thZX3EzS7lt28WV3g4M7JeEoIX8Pm0jCPrOwXq71gra+n92BHIJ685rx X-Received: by 2002:a17:902:8647:b0:17f:63a3:cb48 with SMTP id y7-20020a170902864700b0017f63a3cb48mr21692plt.123.1668443523763; Mon, 14 Nov 2022 08:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668443523; cv=none; d=google.com; s=arc-20160816; b=gh0urKfgIwumSTKdB9EKD+d3xeW78tGl5DvwMqp0Ltka9qtTgM8yzUFVmzFukEOEXw 34yNCfgxv0aPzTf7cIMYY438Y0b1dLeV3Ve/VB530DW6ErbMvXxtoKmL1EK2pzCCdSax d84+fLsiGuW+T062Xb1Yfh2QnuUWtdJVB4SEo1UDpqwQ30wtHGHPGmFkG8bE0mcJ1xHI MTtbr7scC+zykKYam/LKPzvYGn6j04oH3px2mZtJvzeLT8v/VvVrd1W/Y2VuY1eKaXOH K5jhbp9Kd0KM65k7UVEsZmL3FYi9pH+vGjw27RvzdlfvZYfVXsRO2E4kLfw7dkl0oamS 0DuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=WuCvNpqsWpwV49S5/EiT2Eu/MmVMQdF6U0k8ms+rMbY=; b=RVu9M3pV1z4jWzibDXHJkqvXYDIwyO6bDAEvQy0f1Cjc13ixc9j4LlgOH97jwx1Q9y ameT9crfCMuOJcoAMQJLfnjQ7uROo5Qm9QgDkTSG8CUlertkzzDLRn4GJC2yGBv8l4Lb +X9YEMa1kj7vWZViY25snI3aG7EET7CLuSQYejX+JnjeTySEmlMO5uw8ZxzwHnVy+j9E UIR9M9GzLuG5SuT6Mt8/xEPaoxa9SjqeqdIRZsXrYVnl8tXmezhbI4K+U33CRxv/4hcq Sxhzvz7dwbylhFU0QZd45UY3iC5IvTBlASl6q0xI2FBU8Z0b/S7jvUsEA7p2++zZ0H93 sCvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Zq0ro6+R; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a631d04000000b0046fcbcb1015si10340019pgd.331.2022.11.14.08.31.26; Mon, 14 Nov 2022 08:32:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Zq0ro6+R; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237701AbiKNQbD (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Mon, 14 Nov 2022 11:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237624AbiKNQaX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 11:30:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 131552408B for <linux-kernel@vger.kernel.org>; Mon, 14 Nov 2022 08:29:45 -0800 (PST) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668443383; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WuCvNpqsWpwV49S5/EiT2Eu/MmVMQdF6U0k8ms+rMbY=; b=Zq0ro6+RhBlIobVqcIjZKMHr+lsqn6RTbq/4EyeR2al6yeBAOLsUfwzHagX+OpThdDIYBn VZE/aYWC5cQ2/vx6ZAu1VmP+hab3UZ2YzY8SRYMvGEpYirjn96qqYewSqaotEIlUpyiZWd IdQnf2z4Dl6VKKpJ0mR1B4RNgDMnd6gDXi2CXWK5KPeM/1YpW/I0R6dEMqeFNtiwt2WYzs uU3lC8oWM6eohQfmqBlXdguZVOt/A0f6HQHlDRgq63C98P5PZU1stTY4muku6/skYgBZDW RekqyMf3j5W+N8/ukW2hKWe3aGXXoLYUBBeQX8j4E1y6LWIhHkhGsiyOzWca+g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668443383; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WuCvNpqsWpwV49S5/EiT2Eu/MmVMQdF6U0k8ms+rMbY=; b=jh/yhRRxZqyoNHCJ+pkEaPo+hN6JlHwv8X7cSv17o/jCQ4k5FSxhxITDL1Zg48QnQj2yIj DwyFvVmfj7sDM+DA== To: Petr Mladek <pmladek@suse.com> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert@linux-m68k.org>, linux-m68k@lists.linux-m68k.org Subject: [PATCH printk v4 22/39] tty: nfcon: use console_is_registered() Date: Mon, 14 Nov 2022 17:35:15 +0106 Message-Id: <20221114162932.141883-23-john.ogness@linutronix.de> In-Reply-To: <20221114162932.141883-1-john.ogness@linutronix.de> References: <20221114162932.141883-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749489836279415680?= X-GMAIL-MSGID: =?utf-8?q?1749489836279415680?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Nov. 14, 2022, 4:29 p.m. UTC
Currently CON_ENABLED is being (mis)used to identify if the console
has been registered. This is not reliable because it can be set even
though registration failed or it can be unset, even though the console
is registered. Use console_is_registered() instead.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
arch/m68k/emu/nfcon.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
Comments
On Mon 2022-11-14 17:35:15, John Ogness wrote: > Currently CON_ENABLED is being (mis)used to identify if the console > has been registered. This is not reliable because it can be set even > though registration failed or it can be unset, even though the console > is registered. Use console_is_registered() instead. > > Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Best Regards, Petr
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c index 557d60867f98..6fdc13610565 100644 --- a/arch/m68k/emu/nfcon.c +++ b/arch/m68k/emu/nfcon.c @@ -49,7 +49,7 @@ static void nfcon_write(struct console *con, const char *str, static struct tty_driver *nfcon_device(struct console *con, int *index) { *index = 0; - return (con->flags & CON_ENABLED) ? nfcon_tty_driver : NULL; + return console_is_registered(con) ? nfcon_tty_driver : NULL; } static struct console nf_console = { @@ -107,6 +107,11 @@ static int __init nf_debug_setup(char *arg) stderr_id = nf_get_id("NF_STDERR"); if (stderr_id) { + /* + * The console will be enabled when debug=nfcon is specified + * as a kernel parameter. Since this is a non-standard way + * of enabling consoles, it must be explicitly enabled. + */ nf_console.flags |= CON_ENABLED; register_console(&nf_console); } @@ -151,7 +156,7 @@ static int __init nfcon_init(void) nfcon_tty_driver = driver; - if (!(nf_console.flags & CON_ENABLED)) + if (!console_is_registered(&nf_console)) register_console(&nf_console); return 0;