Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp848498rwb; Wed, 16 Nov 2022 08:24:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf7b1dNQfkouJETEi4OO0kgC59XdUMaNMgod9YCzFycejIO5mMVVkXfGZsDwap6yzEkgVh/6 X-Received: by 2002:a05:6402:5a:b0:45a:1bfa:98bf with SMTP id f26-20020a056402005a00b0045a1bfa98bfmr19914091edu.413.1668615892383; Wed, 16 Nov 2022 08:24:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615892; cv=none; d=google.com; s=arc-20160816; b=i94KHEGs1oyvK6IshBrI0LCEySSHu7V+S9EqjB/dYAR2ifS8oA8RlKBLCkaDA+Q2mH kG8ejuOu3HPEQBVisSxr6Z+BiwLL0qfl9+M+p5POzP8k95+h9E065eFRlSaonPbkTcbj 0mGEx2iX8k3IBsFj9vsNEWJrYFy1TXFT96UgKjuM1pYLmy3plH2AgABdNqnhCyR4FZlG mrU/gGOpAoI7ShxkNL2Z+KqLwfPyz17GAqoDsrdJjUYE2stqxuDDwv7zC8KdHJf0lXsR K/046G7bqaFSuETf9uhJJqDPdA+zLetafW5Agsf7GGzfPtdxm5ROsNtVzSlC4LcQe1pi KiOw== 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=EN1ltT10tlp5gUO3+3LVGUGiufYOOsSefqI80mCBCpE=; b=ATCMVMiwzCSvHtgPy/uQ17CwvZK3dMR//+o9hXUbidaaf878u6P+g811TS0iv1f5Ni GDP6cVYLSqE5wrdk7rmijrK0MVl+X75FLj40CgyLmcB9t2CUEnUN1j7pQM8bJpxhk55k zVOienp3LvS83qEnZOkq6QWcFWBibGGBXUWKE5h7sqqRl4t1WqKL9aw8UiNBbb6Wtnza +xQ4vFjpB7eJksTfghz6xI13BiHTVTSZ6hzRs9R2nOrcHJTFyTUwBO4xTdQKbfvAaURo RN93YvUhi+K4ehj4vnDDpw0zQnNfL3q78AHqqjrnJd86PvwAN3WIbJPAvXJtbe1G98IA oGvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WPdwLGjn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=J+8IXAJx; 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 b17-20020a170906661100b00783a5f78700si6090659ejp.226.2022.11.16.08.24.29; Wed, 16 Nov 2022 08:24:52 -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=WPdwLGjn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=J+8IXAJx; 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 S234622AbiKPQWZ (ORCPT + 91 others); Wed, 16 Nov 2022 11:22:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233335AbiKPQWD (ORCPT ); Wed, 16 Nov 2022 11:22:03 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 719E1D135 for ; Wed, 16 Nov 2022 08:22:02 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668615719; 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=EN1ltT10tlp5gUO3+3LVGUGiufYOOsSefqI80mCBCpE=; b=WPdwLGjnnt1bS979u4sLT0ES6LFDbMLi7N2xzKnRQME44bqQm+SOt+o5g2PwviFi9WijgQ RBb99RpeWmpU9pVxhWLn5g66mzj8Ocxc8dWM4RCKpQHhvxbxNzcIZuIOLNtX4Ddq5/xqjd NisGFQFP3XCrWtP/mk6vRNtLLMH7AL/G2UeWNJraDyaD4cJI6YU6+Ge5bnxJojjX9RLEEA jyERdZM67/YAMRMSdktHvTio9Z2FIdZLscXeK2LYEV2DzMUADw1ejELcWjZq+ilM2Gu/ZJ C97woYLBDyIb0aFxgyHR2ZSZsTM696G7/qQ7d2Ue8Hpy9mjFHTtyWAhF5d7XMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668615719; 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=EN1ltT10tlp5gUO3+3LVGUGiufYOOsSefqI80mCBCpE=; b=J+8IXAJxUIi+rarf9xER0OU8t61+ODSJX3QmJ+F9MmZjZaJ14ftCmAo1TTl3sNy7gPAlD9 364wszigXArpVzDg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v5 05/40] printk: move @seq initialization to helper Date: Wed, 16 Nov 2022 17:27:17 +0106 Message-Id: <20221116162152.193147-6-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=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 The code to initialize @seq for a new console needs to consider more factors when choosing an initial value. Move the code into a helper function console_init_seq() "as is" so this code can be expanded without causing register_console() to become too long. A later commit will implement the additional code. Signed-off-by: John Ogness --- kernel/printk/printk.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 3d449dfb1ed6..31d9d1cf8682 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3131,6 +3131,19 @@ static void try_enable_default_console(struct console *newcon) (con->flags & CON_BOOT) ? "boot" : "", \ con->name, con->index, ##__VA_ARGS__) +static void console_init_seq(struct console *newcon) +{ + if (newcon->flags & CON_PRINTBUFFER) { + /* Get a consistent copy of @syslog_seq. */ + mutex_lock(&syslog_lock); + newcon->seq = syslog_seq; + mutex_unlock(&syslog_lock); + } else { + /* Begin with next message. */ + newcon->seq = prb_next_seq(prb); + } +} + #define console_first() \ hlist_entry(console_list.first, struct console, node) @@ -3222,15 +3235,7 @@ void register_console(struct console *newcon) } newcon->dropped = 0; - if (newcon->flags & CON_PRINTBUFFER) { - /* Get a consistent copy of @syslog_seq. */ - mutex_lock(&syslog_lock); - newcon->seq = syslog_seq; - mutex_unlock(&syslog_lock); - } else { - /* Begin with next message. */ - newcon->seq = prb_next_seq(prb); - } + console_init_seq(newcon); /* * Put this console in the list - keep the -- 2.30.2