summaryrefslogtreecommitdiff
path: root/drivers/nvme
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-05-19 10:11:54 +0300
committerChristoph Hellwig <hch@lst.de>2021-06-03 10:29:25 +0300
commitd8ca66e82191a9a95926f7f129028bd362202d5d (patch)
tree7e699c810993c3fae235f119b27c5e316ed5febd /drivers/nvme
parent85b790a7ae0518dd745bbb97d532b83840d2db04 (diff)
downloadlinux-d8ca66e82191a9a95926f7f129028bd362202d5d.tar.xz
nvme: move the CSI sanity check into nvme_ns_report_zones
Move the CSI check into nvme_ns_report_zones to clean up the code a little bit and prepare for further refactoring. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Diffstat (limited to 'drivers/nvme')
-rw-r--r--drivers/nvme/host/zns.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 475dd45c3db4..31e789ecd940 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -180,6 +180,9 @@ static int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
unsigned int nz, i;
size_t buflen;
+ if (ns->head->ids.csi != NVME_CSI_ZNS)
+ return -EINVAL;
+
report = nvme_zns_alloc_report_buffer(ns, nr_zones, &buflen);
if (!report)
return -ENOMEM;
@@ -237,11 +240,7 @@ int nvme_report_zones(struct gendisk *disk, sector_t sector,
ns = nvme_get_ns_from_disk(disk, &head, &srcu_idx);
if (unlikely(!ns))
return -EWOULDBLOCK;
-
- if (ns->head->ids.csi == NVME_CSI_ZNS)
- ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
- else
- ret = -EINVAL;
+ ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
nvme_put_ns_from_disk(head, srcu_idx);
return ret;