From patchwork Mon Nov 7 14:16:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 16459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2079566wru; Mon, 7 Nov 2022 06:22:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM7dDV4jHhNe3sT07gncM1i7/oOXf+VRjr4+gZgcNbsDu0l2a41cczjEramV1y2lYBK8CSRv X-Received: by 2002:a17:907:62a7:b0:789:48ea:ddb0 with SMTP id nd39-20020a17090762a700b0078948eaddb0mr46327692ejc.575.1667830951853; Mon, 07 Nov 2022 06:22:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667830951; cv=none; d=google.com; s=arc-20160816; b=EY6yVKeWzFxJepBB1SKegK5QrPn2m07rWqHV5co8LCSGqxczOTLTChVxrQO2nZNpoW 4mwe0UBypFwwZ5jdzc6fGhWYi7Mdepf8M4d+1saYU2OMoKNNsCXwKdqKGQJG+wr0vV3s shd+QEjrkJ2iEdSicoutSzwm8a+000Hh8HAyNSvJ2iPWpZy7PmR8oK/yOIaZ/ND1Pqhd RVUsFzNpRT6vFRVirnS04Xg9WrPIugbgjoLnFiX8n+iTcGYGw3PbWTDqUxN9xxFywx+7 aovRzXQl3n0msQd+pb+9qxhbOvS3L3Nkd0WIIo/zeA2C2w6zyPgk2/YDgE0CPLmCsjOk DBlA== 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=hTh+Y7bD13JCVuc3SV32h+lY6g8QzK5tRTIXwcqSGfI=; b=Cza9sFRKk8n5akjgJ2mmJdkQ9ugpKUuXfPju9qgUElhc6VgNX2o7MUD9NNfWqny6LO 5Ou18uauMtRV+/V+/VCMG9Xgyp7DOGblUCZkMG9aVitHoN8cWCwp6Vk7ZXvqwqxkmduu hyaoMpjpSYxBOzDIqIeveufdLdorVkpOdgZIFPXP1JqS5gzLMFeXrYiUCVFiAclR5QoH FSM/oMNB5nqA6hK0fbAKVhahRLrSTfsGUpOKV8iBIhskHymy2PmC1lLmK5mdS7iLfJvJ alttulEaHoh4swDcfqjMA+hng9a7mTc5GKnxtuZQcGZqWfa8deMUAUxAQOvLGa42t+3C nmcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vQeoLKWE; 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 eb6-20020a0564020d0600b0046453c39abdsi11312007edb.104.2022.11.07.06.22.06; Mon, 07 Nov 2022 06:22:31 -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=vQeoLKWE; 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 S232380AbiKGOSr (ORCPT + 99 others); Mon, 7 Nov 2022 09:18:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232202AbiKGOQx (ORCPT ); Mon, 7 Nov 2022 09:16:53 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 943D71D0E0 for ; Mon, 7 Nov 2022 06:16:52 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667830611; 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=hTh+Y7bD13JCVuc3SV32h+lY6g8QzK5tRTIXwcqSGfI=; b=vQeoLKWE1k4R6O3nMnBfOLEHIpwhVsbvXcVbHBj6NMymPvMJgyWKk8a+SWMhfut8ws1okf Rqf9Cz5bLPDfyH+IyWepofmoKnEQOGvQ1iHo3uNlukZnoFRP/pK5Sn5O02G21xpmFqMb+u hlTpVg1FSFH8SZ5WJyjH7IZ6QWr3b0vra6/IicriLiXUPXoi2kY+4Ry5gxKoUarCzr9z0L Jn/x7yIxlwj3fKZG/3gv9EsOyIpQRYwIlQqQP0/vFXqq5R1VhYgWlvhKaj+E2sPNiXxMoP PRI0wvXScmB0NbnXYTOF9ujFHajDe8JAN/lBQ8WvjFv+BmWum45rO42CvDc0XA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667830611; 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=hTh+Y7bD13JCVuc3SV32h+lY6g8QzK5tRTIXwcqSGfI=; b=T64AeLS2skGi+8SZjeqwwtVGih9S8IofM6v6ACJ2ABibEKOmMbg6PouGq2vD32FeJ/mS4n /VBpHt26tQKzOUBw== 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 v3 24/40] tty: nfcon: use console_is_registered() Date: Mon, 7 Nov 2022 15:22:22 +0106 Message-Id: <20221107141638.3790965-25-john.ogness@linutronix.de> In-Reply-To: <20221107141638.3790965-1-john.ogness@linutronix.de> References: <20221107141638.3790965-1-john.ogness@linutronix.de> MIME-Version: 1.0 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=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748847508141054346?= X-GMAIL-MSGID: =?utf-8?q?1748847508141054346?= 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. Instead, use console_is_registered(). Signed-off-by: John Ogness Reviewed-by: Geert Uytterhoeven Acked-by: Geert Uytterhoeven --- arch/m68k/emu/nfcon.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c index 557d60867f98..292669fa480f 100644 --- a/arch/m68k/emu/nfcon.c +++ b/arch/m68k/emu/nfcon.c @@ -49,14 +49,14 @@ 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 = { .name = "nfcon", .write = nfcon_write, .device = nfcon_device, - .flags = CON_PRINTBUFFER, + .flags = CON_PRINTBUFFER | CON_ENABLED, .index = -1, }; @@ -106,10 +106,8 @@ static int __init nf_debug_setup(char *arg) return 0; stderr_id = nf_get_id("NF_STDERR"); - if (stderr_id) { - nf_console.flags |= CON_ENABLED; + if (stderr_id) register_console(&nf_console); - } return 0; } @@ -151,7 +149,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;