Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: Christoph Hellwig <hch@lst.de>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230531125535.676098-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
d6545e68 02b42d58

+8 -14
+6 -11
kernel/power/hibernate.c
··· 64 64 static int hibernation_mode = HIBERNATION_SHUTDOWN; 65 65 66 66 bool freezer_test_done; 67 - bool snapshot_test; 68 67 69 68 static const struct platform_hibernation_ops *hibernation_ops; 70 69 ··· 683 684 cpu_relax(); 684 685 } 685 686 686 - static int load_image_and_restore(void) 687 + static int load_image_and_restore(bool snapshot_test) 687 688 { 688 689 int error; 689 690 unsigned int flags; ··· 720 721 */ 721 722 int hibernate(void) 722 723 { 724 + bool snapshot_test = false; 723 725 unsigned int sleep_flags; 724 726 int error; 725 727 ··· 747 747 error = freeze_processes(); 748 748 if (error) 749 749 goto Exit; 750 - 751 - /* protected by system_transition_mutex */ 752 - snapshot_test = false; 753 750 754 751 lock_device_hotplug(); 755 752 /* Allocate memory management structures */ ··· 789 792 unlock_device_hotplug(); 790 793 if (snapshot_test) { 791 794 pm_pr_dbg("Checking hibernation image\n"); 792 - error = swsusp_check(); 795 + error = swsusp_check(snapshot_test); 793 796 if (!error) 794 - error = load_image_and_restore(); 797 + error = load_image_and_restore(snapshot_test); 795 798 } 796 799 thaw_processes(); 797 800 ··· 979 982 */ 980 983 mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING); 981 984 982 - snapshot_test = false; 983 - 984 985 if (!swsusp_resume_device) { 985 986 error = find_resume_device(); 986 987 if (error) ··· 989 994 MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); 990 995 991 996 pm_pr_dbg("Looking for hibernation image.\n"); 992 - error = swsusp_check(); 997 + error = swsusp_check(false); 993 998 if (error) 994 999 goto Unlock; 995 1000 ··· 1017 1022 goto Close_Finish; 1018 1023 } 1019 1024 1020 - error = load_image_and_restore(); 1025 + error = load_image_and_restore(false); 1021 1026 thaw_processes(); 1022 1027 Finish: 1023 1028 pm_notifier_call_chain(PM_POST_RESTORE);
+1 -2
kernel/power/power.h
··· 59 59 60 60 /* kernel/power/hibernate.c */ 61 61 extern bool freezer_test_done; 62 - extern bool snapshot_test; 63 62 64 63 extern int hibernation_snapshot(int platform_mode); 65 64 extern int hibernation_restore(int platform_mode); ··· 173 174 #define SF_HW_SIG 8 174 175 175 176 /* kernel/power/hibernate.c */ 176 - extern int swsusp_check(void); 177 + int swsusp_check(bool snapshot_test); 177 178 extern void swsusp_free(void); 178 179 extern int swsusp_read(unsigned int *flags_p); 179 180 extern int swsusp_write(unsigned int flags);
+1 -1
kernel/power/swap.c
··· 1514 1514 * swsusp_check - Check for swsusp signature in the resume device 1515 1515 */ 1516 1516 1517 - int swsusp_check(void) 1517 + int swsusp_check(bool snapshot_test) 1518 1518 { 1519 1519 int error; 1520 1520 void *holder;