Message ID | 20221019145600.1282823-7-john.ogness@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp378232wrs; Wed, 19 Oct 2022 08:08:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62jwPtOmZx2X7BNDfzGT9IampFoFIToMj37QAQEvxywSzIM9TzXfPeW+I+7gZcVbCSThQl X-Received: by 2002:a17:907:2cd9:b0:78d:9e76:be26 with SMTP id hg25-20020a1709072cd900b0078d9e76be26mr7025052ejc.315.1666192125743; Wed, 19 Oct 2022 08:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192125; cv=none; d=google.com; s=arc-20160816; b=Eh+ukBGmhTvBo8N3bwqln+Kd6Yls1HMiklZ8m3bjhroyBogiJxpPt/zHY0/b3SuEJL Hx5gKwkCQxrye8gdsNiy9sMLV7Va3qkXJn9NZ4A/cGgJsuADr9GM784QKdeBrufqINsg BwxdoLgElxSBt6VNJfmn9qva+bfipjMaHUlah1DWNnFhvYhMOTNajaguiD6nvs//VsVj gUNYWzTYCD8SeFirvpdFr6Da6SM4VuP9HHIVJBFRIKPAp5ChMDvB0grxgy+MHgIyrp6/ 038DC4hGTOksiHbanN4U12WaBP3tSLVm23vj8hnvg8BtUVJP1cx5a+/mlf6WyjUxIebE HTlw== 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=DU0x5O5I9RpJgy/cp3SLsKJQ2S1+Cvd/4SG5pk09kAc=; b=PDDOEE0Yq4WGusvcJlDqYVYU7EUqEKlNqh9IITj1s38fJzqypEvdGVMOvz5RRAPkfH fkrDKgO4iEaJppmmQiOHSjaAuBqV8oxt5/nXoRyKyE3UWrR/64jtgIKNyd5sbcAtW+zZ voJQ5CEvAvyayB6ZXqeRANEQzewxIF/fRhhijaQ9HioSD5kcimzpJCrh0e0lyF2EGiZL DbTBDZ4+ZCkLeAVAC+zdDN3Y6BErlvP7n/gra95zJ7WBF0pf2QA9+X/4MGVElHtEDc6J Jsp1K8WbW30StW9MMq9E7RLs52N8OC+TEzfEGGWuKGzrW3S13xS8tyKg5N7quz6OumyT ReMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lhmCsfzj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 bh11-20020a170906a0cb00b0078d1dc1b64csi11743726ejb.170.2022.10.19.08.08.18; Wed, 19 Oct 2022 08:08:45 -0700 (PDT) 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=lhmCsfzj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231481AbiJSPEd (ORCPT <rfc822;samuel.l.nystrom@gmail.com> + 99 others); Wed, 19 Oct 2022 11:04:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232040AbiJSPEB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 19 Oct 2022 11:04:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B1B18F0DC for <linux-kernel@vger.kernel.org>; Wed, 19 Oct 2022 07:58:30 -0700 (PDT) From: John Ogness <john.ogness@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666191365; 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=DU0x5O5I9RpJgy/cp3SLsKJQ2S1+Cvd/4SG5pk09kAc=; b=lhmCsfzj24k5pXS6vMkayCOEXN89OO2hYrf+P3pHZY5Uc8awoFzbR1WNxWz89ah1Wl1RJN UtRafmMxB4eq47PUYX0qE2iORN8YW29s5ZnDfrP5jUKQPiiyl4BNEdt9VvwdqdaVebgWrb bjZCQqAwv1M/BpWVepcDcISB+HPBPTj0gP6x8ICe9SgTAdYYirF4m5oN4aE32nHj/+shau ApH8MIYM3AoxDo4z+waCfLB1Q2K4qJzeHe88mx4a6J5z85iJKei38O6MWBubQO7AXt30+1 D7HS2H/ONTFe2WaUqzkK+DuLx4bmh5Ovx8UXvnjyCaGMkNqsEVxcRb6DwDCd/Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666191365; 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=DU0x5O5I9RpJgy/cp3SLsKJQ2S1+Cvd/4SG5pk09kAc=; b=l2g6FH6uxwNCpKlJ/oJ3Rl3UvT/3LcZFXUfEnwTA1nqbmIeYdpPfA8BOJpqZVkKkmgCGoD RO2dZOsG0h0CK+AA== 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 v2 06/38] tty: nfcon: use console_is_enabled() Date: Wed, 19 Oct 2022 17:01:28 +0206 Message-Id: <20221019145600.1282823-7-john.ogness@linutronix.de> In-Reply-To: <20221019145600.1282823-1-john.ogness@linutronix.de> References: <20221019145600.1282823-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?1747129074280360967?= X-GMAIL-MSGID: =?utf-8?q?1747129074280360967?= |
Series |
reduce console_lock scope
|
|
Commit Message
John Ogness
Oct. 19, 2022, 2:55 p.m. UTC
Replace (console->flags & CON_ENABLED) usage with console_is_enabled().
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
arch/m68k/emu/nfcon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Wed 2022-10-19 17:01:28, John Ogness wrote: > Replace (console->flags & CON_ENABLED) usage with console_is_enabled(). > > Signed-off-by: John Ogness <john.ogness@linutronix.de> > --- > arch/m68k/emu/nfcon.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c > index 557d60867f98..c542fc2b121f 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_enabled(con) ? nfcon_tty_driver : NULL; > } > > static struct console nf_console = { > @@ -151,7 +151,7 @@ static int __init nfcon_init(void) > > nfcon_tty_driver = driver; > > - if (!(nf_console.flags & CON_ENABLED)) > + if (!console_is_enabled(&nf_console)) Heh, the check of CON_ENABLED does not make much sense. IMHO, the important thing is whether the console is in console_list or not. I would personally add a check at the beginning of register_console() whether the console is already registered and enabled() and do nothing when already done. I would be nice to fix this. But it might be done later. The replacement is straightforward. Both checks are or might be racy. Feel free to use: Reviewed-by: Petr Mladek <pmladek@suse.com> Best Regards, Petr > register_console(&nf_console); > > return 0;
On 2022-10-21, Petr Mladek <pmladek@suse.com> wrote: >> diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c >> index 557d60867f98..c542fc2b121f 100644 >> --- a/arch/m68k/emu/nfcon.c >> +++ b/arch/m68k/emu/nfcon.c >> @@ -151,7 +151,7 @@ static int __init nfcon_init(void) >> >> nfcon_tty_driver = driver; >> >> - if (!(nf_console.flags & CON_ENABLED)) >> + if (!console_is_enabled(&nf_console)) > > Heh, the check of CON_ENABLED does not make much sense. IMHO, the > important thing is whether the console is in console_list or not. > > I would personally add a check at the beginning of register_console() > whether the console is already registered and enabled() and do > nothing when already done. Actually, register_console() already has this check, but it does a WARN(). If the debug setup is used for nfcon, this situation is normal. So probably to avoid the WARN, the CON_ENABLED code was added. > I would be nice to fix this. But it might be done later. I could add a console_is_registered() function that checks if the console is in the console list and use that instead. If we are going to touch this code, we might as well touch it correctly, right? John
On Mon 2022-10-31 17:05:54, John Ogness wrote: > On 2022-10-21, Petr Mladek <pmladek@suse.com> wrote: > >> diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c > >> index 557d60867f98..c542fc2b121f 100644 > >> --- a/arch/m68k/emu/nfcon.c > >> +++ b/arch/m68k/emu/nfcon.c > >> @@ -151,7 +151,7 @@ static int __init nfcon_init(void) > >> > >> nfcon_tty_driver = driver; > >> > >> - if (!(nf_console.flags & CON_ENABLED)) > >> + if (!console_is_enabled(&nf_console)) > > > > Heh, the check of CON_ENABLED does not make much sense. IMHO, the > > important thing is whether the console is in console_list or not. > > > > I would personally add a check at the beginning of register_console() > > whether the console is already registered and enabled() and do > > nothing when already done. > > Actually, register_console() already has this check, but it does a > WARN(). If the debug setup is used for nfcon, this situation is > normal. I see. > So probably to avoid the WARN, the CON_ENABLED code was added. I though more about it. I would keep the warning for the case when the 2nd registration is not intentional. This driver has two ways how the console can be registered. It can happen either in nfcon_init() or in nf_debug_setup(). It is better to have an explicit check to show that it is intentional. > > I would be nice to fix this. But it might be done later. > > I could add a console_is_registered() function that checks if the > console is in the console list and use that instead. If we are going to > touch this code, we might as well touch it correctly, right? It would be great. It is actually much easier after switching to the hlist. Best Regards, Petr
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c index 557d60867f98..c542fc2b121f 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_enabled(con) ? nfcon_tty_driver : NULL; } static struct console nf_console = { @@ -151,7 +151,7 @@ static int __init nfcon_init(void) nfcon_tty_driver = driver; - if (!(nf_console.flags & CON_ENABLED)) + if (!console_is_enabled(&nf_console)) register_console(&nf_console); return 0;