summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Garry <john.g.garry@oracle.com>2026-06-10 11:16:08 +0000
committerKeith Busch <kbusch@kernel.org>2026-06-10 07:33:00 -0700
commit869567bcbe2dcc790860e05fc0e0c5e415bb22c2 (patch)
treecd86e71adbe74080e5f37575cf7aa04e24b29aa3
parentac48c49116d3de84fabc224c6e43f08740b1460d (diff)
nvme: make nvme_add_ns{_head}_cdev return void
The return code from nvme_add_ns_head_cdev() and nvme_add_ns_cdev() is never checked, so make those functions return void. A cdev add failure is tolerated during initialization, and flags NVME_NS_CDEV_LIVE and NVME_NSHEAD_CDEV_LIVE are for determining whether a cdev needs to be deleted during un-initialization. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@kernel.org> Signed-off-by: John Garry <john.g.garry@oracle.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
-rw-r--r--drivers/nvme/host/core.c13
-rw-r--r--drivers/nvme/host/multipath.c13
2 files changed, 10 insertions, 16 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index c6930e43cfea..eb268148acec 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3943,24 +3943,21 @@ static const struct file_operations nvme_ns_chr_fops = {
.uring_cmd_iopoll = nvme_ns_chr_uring_cmd_iopoll,
};
-static int nvme_add_ns_cdev(struct nvme_ns *ns)
+static void nvme_add_ns_cdev(struct nvme_ns *ns)
{
- int ret;
char name[32];
ns->cdev_device.parent = ns->ctrl->device;
snprintf(name, sizeof(name), "ng%dn%d", ns->ctrl->instance,
ns->head->instance);
- ret = nvme_cdev_add(name, &ns->cdev, &ns->cdev_device,
- &nvme_ns_chr_fops, ns->ctrl->ops->module);
- if (ret) {
+ if (nvme_cdev_add(name, &ns->cdev, &ns->cdev_device,
+ &nvme_ns_chr_fops, ns->ctrl->ops->module)) {
dev_err(ns->ctrl->device, "Unable to create the %s device\n",
name);
- } else {
- set_bit(NVME_NS_CDEV_LIVE, &ns->flags);
+ return;
}
- return ret;
+ set_bit(NVME_NS_CDEV_LIVE, &ns->flags);
}
static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 9cd49e2f760d..9b9a657fa330 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -639,24 +639,21 @@ static const struct file_operations nvme_ns_head_chr_fops = {
.uring_cmd_iopoll = nvme_ns_chr_uring_cmd_iopoll,
};
-static int nvme_add_ns_head_cdev(struct nvme_ns_head *head)
+static void nvme_add_ns_head_cdev(struct nvme_ns_head *head)
{
- int ret;
char name[32];
head->cdev_device.parent = &head->subsys->dev;
snprintf(name, sizeof(name), "ng%dn%d", head->subsys->instance,
head->instance);
- ret = nvme_cdev_add(name, &head->cdev, &head->cdev_device,
- &nvme_ns_head_chr_fops, THIS_MODULE);
- if (ret) {
+ if (nvme_cdev_add(name, &head->cdev, &head->cdev_device,
+ &nvme_ns_head_chr_fops, THIS_MODULE)) {
dev_err(disk_to_dev(head->disk),
"Unable to create the %s device\n", name);
- } else {
- set_bit(NVME_NSHEAD_CDEV_LIVE, &head->flags);
+ return;
}
- return ret;
+ set_bit(NVME_NSHEAD_CDEV_LIVE, &head->flags);
}
static void nvme_partition_scan_work(struct work_struct *work)