Commit d6545e68 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

PM: hibernate: remove the global snapshot_test variable

Passing call dependent variable in global variables is a huge
antipattern.  Fix it up.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230531125535.676098-4-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 02b42d58
...@@ -64,7 +64,6 @@ enum { ...@@ -64,7 +64,6 @@ enum {
static int hibernation_mode = HIBERNATION_SHUTDOWN; static int hibernation_mode = HIBERNATION_SHUTDOWN;
bool freezer_test_done; bool freezer_test_done;
bool snapshot_test;
static const struct platform_hibernation_ops *hibernation_ops; static const struct platform_hibernation_ops *hibernation_ops;
...@@ -684,7 +683,7 @@ static void power_down(void) ...@@ -684,7 +683,7 @@ static void power_down(void)
cpu_relax(); cpu_relax();
} }
static int load_image_and_restore(void) static int load_image_and_restore(bool snapshot_test)
{ {
int error; int error;
unsigned int flags; unsigned int flags;
...@@ -721,6 +720,7 @@ static int load_image_and_restore(void) ...@@ -721,6 +720,7 @@ static int load_image_and_restore(void)
*/ */
int hibernate(void) int hibernate(void)
{ {
bool snapshot_test = false;
unsigned int sleep_flags; unsigned int sleep_flags;
int error; int error;
...@@ -748,9 +748,6 @@ int hibernate(void) ...@@ -748,9 +748,6 @@ int hibernate(void)
if (error) if (error)
goto Exit; goto Exit;
/* protected by system_transition_mutex */
snapshot_test = false;
lock_device_hotplug(); lock_device_hotplug();
/* Allocate memory management structures */ /* Allocate memory management structures */
error = create_basic_memory_bitmaps(); error = create_basic_memory_bitmaps();
...@@ -792,9 +789,9 @@ int hibernate(void) ...@@ -792,9 +789,9 @@ int hibernate(void)
unlock_device_hotplug(); unlock_device_hotplug();
if (snapshot_test) { if (snapshot_test) {
pm_pr_dbg("Checking hibernation image\n"); pm_pr_dbg("Checking hibernation image\n");
error = swsusp_check(); error = swsusp_check(snapshot_test);
if (!error) if (!error)
error = load_image_and_restore(); error = load_image_and_restore(snapshot_test);
} }
thaw_processes(); thaw_processes();
...@@ -982,8 +979,6 @@ static int software_resume(void) ...@@ -982,8 +979,6 @@ static int software_resume(void)
*/ */
mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING); mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING);
snapshot_test = false;
if (!swsusp_resume_device) { if (!swsusp_resume_device) {
error = find_resume_device(); error = find_resume_device();
if (error) if (error)
...@@ -994,7 +989,7 @@ static int software_resume(void) ...@@ -994,7 +989,7 @@ static int software_resume(void)
MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device));
pm_pr_dbg("Looking for hibernation image.\n"); pm_pr_dbg("Looking for hibernation image.\n");
error = swsusp_check(); error = swsusp_check(false);
if (error) if (error)
goto Unlock; goto Unlock;
...@@ -1022,7 +1017,7 @@ static int software_resume(void) ...@@ -1022,7 +1017,7 @@ static int software_resume(void)
goto Close_Finish; goto Close_Finish;
} }
error = load_image_and_restore(); error = load_image_and_restore(false);
thaw_processes(); thaw_processes();
Finish: Finish:
pm_notifier_call_chain(PM_POST_RESTORE); pm_notifier_call_chain(PM_POST_RESTORE);
......
...@@ -59,7 +59,6 @@ asmlinkage int swsusp_save(void); ...@@ -59,7 +59,6 @@ asmlinkage int swsusp_save(void);
/* kernel/power/hibernate.c */ /* kernel/power/hibernate.c */
extern bool freezer_test_done; extern bool freezer_test_done;
extern bool snapshot_test;
extern int hibernation_snapshot(int platform_mode); extern int hibernation_snapshot(int platform_mode);
extern int hibernation_restore(int platform_mode); extern int hibernation_restore(int platform_mode);
...@@ -174,7 +173,7 @@ extern int swsusp_swap_in_use(void); ...@@ -174,7 +173,7 @@ extern int swsusp_swap_in_use(void);
#define SF_HW_SIG 8 #define SF_HW_SIG 8
/* kernel/power/hibernate.c */ /* kernel/power/hibernate.c */
extern int swsusp_check(void); int swsusp_check(bool snapshot_test);
extern void swsusp_free(void); extern void swsusp_free(void);
extern int swsusp_read(unsigned int *flags_p); extern int swsusp_read(unsigned int *flags_p);
extern int swsusp_write(unsigned int flags); extern int swsusp_write(unsigned int flags);
......
...@@ -1514,7 +1514,7 @@ int swsusp_read(unsigned int *flags_p) ...@@ -1514,7 +1514,7 @@ int swsusp_read(unsigned int *flags_p)
* swsusp_check - Check for swsusp signature in the resume device * swsusp_check - Check for swsusp signature in the resume device
*/ */
int swsusp_check(void) int swsusp_check(bool snapshot_test)
{ {
int error; int error;
void *holder; void *holder;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment