public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>
Cc: Minwoo Im <minwoo.im.dev@gmail.com>, linux-nvme@lists.infradead.org
Subject: [PATCH 5/7] nvme: move the CSI sanity check into nvme_ns_report_zones
Date: Thu, 20 May 2021 07:44:24 +0200	[thread overview]
Message-ID: <20210520054426.567241-6-hch@lst.de> (raw)
In-Reply-To: <20210520054426.567241-1-hch@lst.de>

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>
---
 drivers/nvme/host/zns.c | 9 ++++-----
 1 file 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;
-- 
2.30.2


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2021-05-20  5:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20  5:44 misc nvme ioctl cleanups Christoph Hellwig
2021-05-20  5:44 ` [PATCH 1/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_chr_ioctl Christoph Hellwig
2021-05-20  5:44 ` [PATCH 2/7] nvne: open code nvme_{get, put}_ns_from_disk in nvme_ns_head_ioctl Christoph Hellwig
2021-05-20  5:44 ` [PATCH 3/7] nvme: open code nvme_put_ns_from_disk in nvme_ns_head_ctrl_ioctl Christoph Hellwig
2021-05-20  5:44 ` [PATCH 4/7] nvme: add a sparse annotation to nvme_ns_head_ctrl_ioctl Christoph Hellwig
2021-05-20  5:44 ` Christoph Hellwig [this message]
2021-05-20  5:44 ` [PATCH 6/7] nvme: split nvme_report_zones Christoph Hellwig
2021-05-20  5:44 ` [PATCH 7/7] nvme: remove nvme_{get,put}_ns_from_disk Christoph Hellwig
2021-05-20 15:38 ` misc nvme ioctl cleanups Keith Busch
2021-05-20 22:36   ` Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210520054426.567241-6-hch@lst.de \
    --to=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=minwoo.im.dev@gmail.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox