Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5784038rwb; Mon, 14 Nov 2022 09:21:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf5sJrP6LTHEeOcvmA3pv8W9t4PokYFIcLX90byfJOvDG+z5D89xyujXygU+aWXdxZUyTe+I X-Received: by 2002:a17:903:2696:b0:17f:5778:888b with SMTP id jf22-20020a170903269600b0017f5778888bmr188543plb.119.1668446513990; Mon, 14 Nov 2022 09:21:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668446513; cv=none; d=google.com; s=arc-20160816; b=IauJmPDhZGJNJ++gTkgNMXSA2xxXAgjUpVuvAUZzD+yYDKPs9UvB0f3Dj8z5iVUQRD eIre+L+D6d89brNRChxLXP1TOPU9JmIhV1U0AfJ8u7nHwZ2BU0JlgRDoG2lpJRznETiD aBdeeTUuGWSkQNp7ZHstp1wRjh+opmE1P7tFVD4BGv4KNHi3bIXq21vf7xvJ7xiUiVzQ xOK/V4ZWelt8n+BXPTb5l+eZ2KeD6B9oA+pt2fVcu8+nhxsYQ20Lp4GTRTq0eg6SaenL p2auXk6sS2k35gJL7tdRqvoHA0wDl+XJ9VX4BYwdEiexTLCZCzDYE3e7FohHCMriDbwz WjWw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a635457000000b0046b3ba2c806si10090273pgm.145.2022.11.14.09.21.41; Mon, 14 Nov 2022 09:21:53 -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 + 87 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 ); 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 ; Mon, 14 Nov 2022 08:29:45 -0800 (PST) From: John Ogness 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 Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Geert Uytterhoeven , 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/m68k/emu/nfcon.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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; -- 2.30.2