Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp896721rwb; Wed, 16 Nov 2022 09:04:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4kA0yJHNaVoKdos6X8B+Aasn8xaNpfghlgn6/zrBDz6CEUrEFKuP5rmEPbBmAODcOIjXdC X-Received: by 2002:a63:7884:0:b0:470:48c2:3aa1 with SMTP id t126-20020a637884000000b0047048c23aa1mr21072058pgc.45.1668618267686; Wed, 16 Nov 2022 09:04:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668618267; cv=none; d=google.com; s=arc-20160816; b=T3SyU873kMFTRj2EDYLSnni8krslLBMnSi8Pkmm0fVok1L/ZBhKK8NZerJr/V55oXH ntPVkb27s63h0SBw7lRleA8vx1GM2+rX/AXkzzmbBhGFXu+OtWZlyM++AzDHEv/zfV/R xEKJL6z0UWXd5Mx9Zc4wQTlUbChNWWNvDyApvrMS3qo4ThmM61/SBIouDpYOJO49lfsg fzHlRI7Tp9DdvOVpJ9QT/j2JyYYOzINwwRhw0vrkyV4DkwkcriyaLvOnqKxNAhLQYMXV hmBJEQ0mOpMH1sRCGB1TCmaB4qnqUG+8KG3mW9LLg8Z+mbkORvLqql1uR3xb/M/nc1hJ Nqgg== 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=W6b5NfOqKhbCO1n0vtfDs0FHEhscqKbHgSYvxQsImbM=; b=We1pfvEd3vtJJz6LMvH+Nd4S/wJm9hhM3PMYIEfKY2wUIrvGpaV0el8lCN0WB+drcJ 9qyrriWw+6jAPibIwzUdrL11lbbHzZyomnqeyF4NVrFd/0tkU3D4sYrpzB8iA2mK8wa/ GLRJCIb1z/MGHgXCCAZGEmllp1fsO6vx/Bv65KKCvaercuV3PMGiM7C9cCXtzRMzYPiI 69QWWNEnxsb4Nd62ls9ytlRy5mCuB7c9nxnxxcSwHCmeETevy4ib/4UtyFDTl9SWfhAD aN6LHBZ2RxgtLGfK2aeY5SJ9DrP3fShKSvk/xWHYmjbbaAoLlYdaoSdPCooCi1q8mkRj 9ptQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IBcr1RxL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=aCdGy65F; 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 y10-20020a17090322ca00b00188758ff467si17558449plg.29.2022.11.16.09.03.50; Wed, 16 Nov 2022 09:04:27 -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=IBcr1RxL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=aCdGy65F; 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 S233528AbiKPQYn (ORCPT + 91 others); Wed, 16 Nov 2022 11:24:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234852AbiKPQWi (ORCPT ); Wed, 16 Nov 2022 11:22:38 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4655C56EE3 for ; Wed, 16 Nov 2022 08:22:09 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615727; 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=W6b5NfOqKhbCO1n0vtfDs0FHEhscqKbHgSYvxQsImbM=; b=IBcr1RxLLQMeyECtbEihD5+SDG2qe7fRWjloWrZA2o4slYup3U8euFE14aIPz1HRHxa183 CoHwh0r1nnCCq/kVLBav99fCpMmwf8HbZod20k0BgxGL3/QduwfUoc1od2xf8BJO7CCnvD ygTXemlU10X5pYiBYBpz+zh3Tvr8uDTkvgrL2EfBOOHirNL1k0XkHhbx0MT2by9Y+1+P3j ScpGGGr3ZzrLsRGMSh2ggRF5U/snEVrx5Dg4KAcbJvvvDqKhlIJ/B/vLWWNT5/AMv17/2+ TvXximoOPlAMtZWKZ/+Li4h/lLdlVYU1BqLOiJ08cZqYOylus+X8wJZkoC3Jcg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615727; 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=W6b5NfOqKhbCO1n0vtfDs0FHEhscqKbHgSYvxQsImbM=; b=aCdGy65F2gyHzwQcJS4XmrabRrVViXls9okyGZ3p0ecSnxm0D+X6Mq6XYE9k0CGaxAQFeW TyAwIYANT63+pfBQ== 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 v5 23/40] tty: nfcon: use console_is_registered() Date: Wed, 16 Nov 2022 17:27:35 +0106 Message-Id: <20221116162152.193147-24-john.ogness@linutronix.de> In-Reply-To: <20221116162152.193147-1-john.ogness@linutronix.de> References: <20221116162152.193147-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 Reviewed-by: Petr Mladek --- 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