Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp851603rwd; Wed, 31 May 2023 06:22:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zYFRrZ3ucMQ/oMcuYrl5QKF2MhtMEPmKm1YQ9g0aNQHDzdx48rB67Yb3OmxyKY0p5KIgs X-Received: by 2002:a17:902:ecc2:b0:1ad:8c8f:afb1 with SMTP id a2-20020a170902ecc200b001ad8c8fafb1mr5205225plh.39.1685539355118; Wed, 31 May 2023 06:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685539355; cv=none; d=google.com; s=arc-20160816; b=Alc0lCPwUnmDZVCj+Q+HqgJ4BX+iBDO/s/1MJsgck8FOTPytB1inBBMPuVamc3UQbi dQ5+SMmhQDRnrEf8YWiCY3Z+U7znqcHg5vK/y87j/Aekr4d6lcFkAxrHUFpWA0GTXT3o ndsABjeZDMHwuZO61hFsSm05ipgDiG0VJPoz+DJrfbKAuKPVb4D5TXV8jyQw16u1lN6Q god6yAClD+sTF2zPDVbO8APy2g3aiKiJV5dRblP99MkqTZtxJvFJqkXl3RH/XrYXr6LG EndlWoM6+td7HTAxcAH6Bfx3TuQWApPWT3vnrX8XFE98oSS7/0zbOSL1JfHr1iYCkuBZ W1eQ== 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:from :dkim-signature; bh=AmHMaGciyZumE4aVkyv6UwavmqIcFHl8yaRqRVfDzhM=; b=oz7S9IOcKmrRebHov1knjeAeqo8qwrzU3oxrIjGfBp7iFTc6X9fU6QFVG1rp8nKn5d pdeP+HOYnG/ZixJeZBNn57VWvqsM6nzZolSyOY6m9icEkf7Wh6CzpKb5x1fifLRnXOIw ZP0eYQvYY6gbBXtFPRVDg1L0q4YFoG8HVNNMXFBQK/yxbga7jcofLi3OjQLeiETaf8cD 8a6Rr1bIlZV/Uq/o048hUxfTzQccNJdWJA+avAvwgnqNEGKtuzf3FfB2deUTiP5n0XsH W1oGsu7WPpsJUStT6uj9iOsNv3SSMOFYlbi4WA+j+q3wgKjiPBEumSy7xJw7SB+iefCR CZWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=NsM8t9GA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb4-20020a170903258400b001b04c325d66si816108plb.565.2023.05.31.06.22.21; Wed, 31 May 2023 06:22:35 -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=@infradead.org header.s=bombadil.20210309 header.b=NsM8t9GA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236093AbjEaM4p (ORCPT + 99 others); Wed, 31 May 2023 08:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236073AbjEaM4d (ORCPT ); Wed, 31 May 2023 08:56:33 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42190129; Wed, 31 May 2023 05:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=AmHMaGciyZumE4aVkyv6UwavmqIcFHl8yaRqRVfDzhM=; b=NsM8t9GA8hmexagtW2AzKtnA0e Z+UPA1K2V+XTF4g2vk5DkSw6j7IEsplDglWCsKaGG8ztKFFfTbdJQ5mnROhRbT+ni9eCsYXI18cOY WUvCo0K/lGrJR07dM+ilbcQAw/l5CbITDmKpQw5NI/bQLMrXYhpAmXF8U861hgVn40la7JDceSpQ+ LlHC9/l5g2wqqOPM0spQIyZ/Sri6AzoZyWG5VkvLrp54M+fM81W+N8ZZ6zi9hY1ro0srtQHX9uezm lsN2V15kqrmCN9iAYq7Tp1WgaK0ePOQd7Lp4+KMwvf1qXOodZoRJpp58c9aF/7iBRaH84FAxPPZNE NMnYPv6Q==; Received: from [2001:4bb8:182:6d06:2e49:a56:513a:92ee] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4LMq-00HQy6-2x; Wed, 31 May 2023 12:55:57 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Mike Snitzer , Joern Engel , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Pavel Machek , Loic Poulain , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH 03/24] PM: hibernate: remove the global snapshot_test variable Date: Wed, 31 May 2023 14:55:14 +0200 Message-Id: <20230531125535.676098-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531125535.676098-1-hch@lst.de> References: <20230531125535.676098-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Passing call dependent variable in global variables is a huge antipattern. Fix it up. Signed-off-by: Christoph Hellwig Acked-by: Rafael J. Wysocki --- kernel/power/hibernate.c | 17 ++++++----------- kernel/power/power.h | 3 +-- kernel/power/swap.c | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 07279506366255..78696aa04f5ca3 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -64,7 +64,6 @@ enum { static int hibernation_mode = HIBERNATION_SHUTDOWN; bool freezer_test_done; -bool snapshot_test; static const struct platform_hibernation_ops *hibernation_ops; @@ -684,7 +683,7 @@ static void power_down(void) cpu_relax(); } -static int load_image_and_restore(void) +static int load_image_and_restore(bool snapshot_test) { int error; unsigned int flags; @@ -721,6 +720,7 @@ static int load_image_and_restore(void) */ int hibernate(void) { + bool snapshot_test = false; unsigned int sleep_flags; int error; @@ -748,9 +748,6 @@ int hibernate(void) if (error) goto Exit; - /* protected by system_transition_mutex */ - snapshot_test = false; - lock_device_hotplug(); /* Allocate memory management structures */ error = create_basic_memory_bitmaps(); @@ -792,9 +789,9 @@ int hibernate(void) unlock_device_hotplug(); if (snapshot_test) { pm_pr_dbg("Checking hibernation image\n"); - error = swsusp_check(); + error = swsusp_check(snapshot_test); if (!error) - error = load_image_and_restore(); + error = load_image_and_restore(snapshot_test); } thaw_processes(); @@ -982,8 +979,6 @@ static int software_resume(void) */ mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING); - snapshot_test = false; - if (!swsusp_resume_device) { error = find_resume_device(); if (error) @@ -994,7 +989,7 @@ static int software_resume(void) MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); pm_pr_dbg("Looking for hibernation image.\n"); - error = swsusp_check(); + error = swsusp_check(false); if (error) goto Unlock; @@ -1022,7 +1017,7 @@ static int software_resume(void) goto Close_Finish; } - error = load_image_and_restore(); + error = load_image_and_restore(false); thaw_processes(); Finish: pm_notifier_call_chain(PM_POST_RESTORE); diff --git a/kernel/power/power.h b/kernel/power/power.h index b83c8d5e188dec..978189fcafd124 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -59,7 +59,6 @@ asmlinkage int swsusp_save(void); /* kernel/power/hibernate.c */ extern bool freezer_test_done; -extern bool snapshot_test; extern int hibernation_snapshot(int platform_mode); extern int hibernation_restore(int platform_mode); @@ -174,7 +173,7 @@ extern int swsusp_swap_in_use(void); #define SF_HW_SIG 8 /* kernel/power/hibernate.c */ -extern int swsusp_check(void); +int swsusp_check(bool snapshot_test); extern void swsusp_free(void); extern int swsusp_read(unsigned int *flags_p); extern int swsusp_write(unsigned int flags); diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 92e41ed292ada8..efed11568bfc72 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -1514,7 +1514,7 @@ int swsusp_read(unsigned int *flags_p) * swsusp_check - Check for swsusp signature in the resume device */ -int swsusp_check(void) +int swsusp_check(bool snapshot_test) { int error; void *holder; -- 2.39.2