All of lore.kernel.org
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>,
	Max Reitz <mreitz@redhat.com>, Keith Busch <kbusch@kernel.org>,
	Klaus Jensen <its@irrelevant.dk>
Subject: [PATCH 07/14] hw/block/nvme: replace nvme_ns_status
Date: Mon, 19 Apr 2021 21:27:54 +0200	[thread overview]
Message-ID: <20210419192801.62255-8-its@irrelevant.dk> (raw)
In-Reply-To: <20210419192801.62255-1-its@irrelevant.dk>

From: Klaus Jensen <k.jensen@samsung.com>

The inline nvme_ns_status() helper only has a single call site. Remove
it from the header file and inline it for real.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/block/nvme.h |  5 -----
 hw/block/nvme.c | 15 ++++++++-------
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index 2c4e7b90fa54..d9bee7e5a05c 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -137,11 +137,6 @@ typedef struct NvmeNamespace {
     } features;
 } NvmeNamespace;
 
-static inline uint16_t nvme_ns_status(NvmeNamespace *ns)
-{
-    return ns->status;
-}
-
 static inline uint32_t nvme_nsid(NvmeNamespace *ns)
 {
     if (ns) {
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 2c0af579e7a8..bcef6038ae09 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -3594,8 +3594,8 @@ static uint16_t nvme_zone_mgmt_recv(NvmeCtrl *n, NvmeRequest *req)
 
 static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
 {
+    NvmeNamespace *ns;
     uint32_t nsid = le32_to_cpu(req->cmd.nsid);
-    uint16_t status;
 
     trace_pci_nvme_io_cmd(nvme_cid(req), nsid, nvme_sqid(req),
                           req->cmd.opcode, nvme_io_opc_str(req->cmd.opcode));
@@ -3627,21 +3627,22 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
         return nvme_flush(n, req);
     }
 
-    req->ns = nvme_ns(n, nsid);
-    if (unlikely(!req->ns)) {
+    ns = nvme_ns(n, nsid);
+    if (unlikely(!ns)) {
         return NVME_INVALID_FIELD | NVME_DNR;
     }
 
-    if (!(req->ns->iocs[req->cmd.opcode] & NVME_CMD_EFF_CSUPP)) {
+    if (!(ns->iocs[req->cmd.opcode] & NVME_CMD_EFF_CSUPP)) {
         trace_pci_nvme_err_invalid_opc(req->cmd.opcode);
         return NVME_INVALID_OPCODE | NVME_DNR;
     }
 
-    status = nvme_ns_status(req->ns);
-    if (unlikely(status)) {
-        return status;
+    if (ns->status) {
+        return ns->status;
     }
 
+    req->ns = ns;
+
     switch (req->cmd.opcode) {
     case NVME_CMD_WRITE_ZEROES:
         return nvme_write_zeroes(n, req);
-- 
2.31.1



  parent reply	other threads:[~2021-04-19 20:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 19:27 [PATCH 00/14] hw(/block/)nvme: spring cleaning Klaus Jensen
2021-04-19 19:27 ` [PATCH 01/14] hw/block/nvme: rename __nvme_zrm_open Klaus Jensen
2021-04-20  5:53   ` Thomas Huth
2021-04-20  7:16     ` Klaus Jensen
2021-04-19 19:27 ` [PATCH 02/14] hw/block/nvme: rename __nvme_advance_zone_wp Klaus Jensen
2021-04-20  5:53   ` Thomas Huth
2021-04-19 19:27 ` [PATCH 03/14] hw/block/nvme: rename __nvme_select_ns_iocs Klaus Jensen
2021-04-20  5:56   ` Thomas Huth
2021-04-19 19:27 ` [PATCH 04/14] hw/block/nvme: consolidate header files Klaus Jensen
2021-04-19 19:27 ` [PATCH 05/14] hw/block/nvme: cleanup includes Klaus Jensen
2021-04-19 19:27 ` [PATCH 06/14] hw/block/nvme: remove non-shared defines from header file Klaus Jensen
2021-04-19 19:27 ` Klaus Jensen [this message]
2021-04-19 19:27 ` [PATCH 08/14] hw/block/nvme: cache lba and ms sizes Klaus Jensen
2021-04-19 19:27 ` [PATCH 09/14] hw/block/nvme: add metadata offset helper Klaus Jensen
2021-04-19 19:27 ` [PATCH 10/14] hw/block/nvme: streamline namespace array indexing Klaus Jensen
2021-04-19 19:27 ` [PATCH 11/14] hw/block/nvme: remove num_namespaces member Klaus Jensen
2021-04-19 19:27 ` [PATCH 12/14] hw/block/nvme: remove irrelevant zone resource checks Klaus Jensen
2021-04-19 19:28 ` [PATCH 13/14] hw/block/nvme: move zoned constraints checks Klaus Jensen
2021-04-19 19:28 ` [PATCH 14/14] hw/nvme: move nvme emulation out of hw/block Klaus Jensen
2021-04-21 18:04   ` Klaus Jensen
2021-04-20 17:22 ` [PATCH 00/14] hw(/block/)nvme: spring cleaning Keith Busch
2021-04-26  8:02 ` Klaus Jensen

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=20210419192801.62255-8-its@irrelevant.dk \
    --to=its@irrelevant.dk \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --subject='Re: [PATCH 07/14] hw/block/nvme: replace nvme_ns_status' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.