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: factor out a helper to find the resume device

Split the logic to find the resume device out software_resume and into
a separate helper to start unwindig the convoluted goto logic.

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

authored by

Christoph Hellwig and committed by
Jens Axboe
02b42d58 aa5f6ed8

+37 -35
+37 -35
kernel/power/hibernate.c
··· 910 910 } 911 911 EXPORT_SYMBOL_GPL(hibernate_quiet_exec); 912 912 913 + static int find_resume_device(void) 914 + { 915 + if (!strlen(resume_file)) 916 + return -ENOENT; 917 + 918 + pm_pr_dbg("Checking hibernation image partition %s\n", resume_file); 919 + 920 + if (resume_delay) { 921 + pr_info("Waiting %dsec before reading resume device ...\n", 922 + resume_delay); 923 + ssleep(resume_delay); 924 + } 925 + 926 + /* Check if the device is there */ 927 + swsusp_resume_device = name_to_dev_t(resume_file); 928 + if (swsusp_resume_device) 929 + return 0; 930 + 931 + /* 932 + * Some device discovery might still be in progress; we need to wait for 933 + * this to finish. 934 + */ 935 + wait_for_device_probe(); 936 + if (resume_wait) { 937 + while (!(swsusp_resume_device = name_to_dev_t(resume_file))) 938 + msleep(10); 939 + async_synchronize_full(); 940 + } 941 + 942 + swsusp_resume_device = name_to_dev_t(resume_file); 943 + if (!swsusp_resume_device) 944 + return -ENODEV; 945 + return 0; 946 + } 947 + 913 948 /** 914 949 * software_resume - Resume from a saved hibernation image. 915 950 * ··· 984 949 985 950 snapshot_test = false; 986 951 987 - if (swsusp_resume_device) 988 - goto Check_image; 989 - 990 - if (!strlen(resume_file)) { 991 - error = -ENOENT; 992 - goto Unlock; 993 - } 994 - 995 - pm_pr_dbg("Checking hibernation image partition %s\n", resume_file); 996 - 997 - if (resume_delay) { 998 - pr_info("Waiting %dsec before reading resume device ...\n", 999 - resume_delay); 1000 - ssleep(resume_delay); 1001 - } 1002 - 1003 - /* Check if the device is there */ 1004 - swsusp_resume_device = name_to_dev_t(resume_file); 1005 952 if (!swsusp_resume_device) { 1006 - /* 1007 - * Some device discovery might still be in progress; we need 1008 - * to wait for this to finish. 1009 - */ 1010 - wait_for_device_probe(); 1011 - 1012 - if (resume_wait) { 1013 - while ((swsusp_resume_device = name_to_dev_t(resume_file)) == 0) 1014 - msleep(10); 1015 - async_synchronize_full(); 1016 - } 1017 - 1018 - swsusp_resume_device = name_to_dev_t(resume_file); 1019 - if (!swsusp_resume_device) { 1020 - error = -ENODEV; 953 + error = find_resume_device(); 954 + if (error) 1021 955 goto Unlock; 1022 - } 1023 956 } 1024 957 1025 - Check_image: 1026 958 pm_pr_dbg("Hibernation image partition %d:%d present\n", 1027 959 MAJOR(swsusp_resume_device), MINOR(swsusp_resume_device)); 1028 960