summaryrefslogtreecommitdiffstats
path: root/kernel/power
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-05-31 14:55:24 +0200
committerJens Axboe <axboe@kernel.dk>2023-06-05 18:56:46 +0200
commitcf056a43121559d3642419917d405c3237ded90a (patch)
treecf61d333adf4d030bf719d814a9aec20e99fe00b /kernel/power
parentinit: move the nfs/cifs/ram special cases out of name_to_dev_t (diff)
downloadlinux-cf056a43121559d3642419917d405c3237ded90a.tar.xz
linux-cf056a43121559d3642419917d405c3237ded90a.zip
init: improve the name_to_dev_t interface
name_to_dev_t has a very misleading name, that doesn't make clear it should only be used by the early init code, and also has a bad calling convention that doesn't allow returning different kinds of errors. Rename it to early_lookup_bdev to make the use case clear, and return an errno, where -EINVAL means the string could not be parsed, and -ENODEV means it the string was valid, but there was no device found for it. Also stub out the whole call for !CONFIG_BLOCK as all the non-block root cases are always covered in the caller. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20230531125535.676098-14-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/hibernate.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 45e24b02cd50..c52dedb9f7c8 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -11,6 +11,7 @@
#define pr_fmt(fmt) "PM: hibernation: " fmt
+#include <linux/blkdev.h>
#include <linux/export.h>
#include <linux/suspend.h>
#include <linux/reboot.h>
@@ -921,8 +922,7 @@ static int __init find_resume_device(void)
}
/* Check if the device is there */
- swsusp_resume_device = name_to_dev_t(resume_file);
- if (swsusp_resume_device)
+ if (!early_lookup_bdev(resume_file, &swsusp_resume_device))
return 0;
/*
@@ -931,15 +931,12 @@ static int __init find_resume_device(void)
*/
wait_for_device_probe();
if (resume_wait) {
- while (!(swsusp_resume_device = name_to_dev_t(resume_file)))
+ while (early_lookup_bdev(resume_file, &swsusp_resume_device))
msleep(10);
async_synchronize_full();
}
- swsusp_resume_device = name_to_dev_t(resume_file);
- if (!swsusp_resume_device)
- return -ENODEV;
- return 0;
+ return early_lookup_bdev(resume_file, &swsusp_resume_device);
}
static int software_resume(void)
@@ -1169,7 +1166,8 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
unsigned int sleep_flags;
int len = n;
char *name;
- dev_t res;
+ dev_t dev;
+ int error;
if (!hibernation_available())
return 0;
@@ -1180,13 +1178,13 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
if (!name)
return -ENOMEM;
- res = name_to_dev_t(name);
+ error = early_lookup_bdev(name, &dev);
kfree(name);
- if (!res)
- return -EINVAL;
+ if (error)
+ return error;
sleep_flags = lock_system_sleep();
- swsusp_resume_device = res;
+ swsusp_resume_device = dev;
unlock_system_sleep(sleep_flags);
pm_pr_dbg("Configured hibernation resume from disk to %u\n",