From: ednadols@linux.microsoft.com (Edmund Nadolski)
Subject: [PATCH 1/2] nvme: nvme_set_queue_count should use descriptive macros
Date: Mon, 29 Apr 2019 10:35:32 -0700 [thread overview]
Message-ID: <20190429173533.10366-2-ednadols@linux.microsoft.com> (raw)
In-Reply-To: <20190429173533.10366-1-ednadols@linux.microsoft.com>
Implement macros to set/get the number of submission and/or completion
queues requested by the Set Features command. This replaces the bit
masking/shifting code which is harder to read and more error prone to
maintain.
Signed-off-by: Edmund Nadolski <ednadols at linux.microsoft.com>
---
drivers/nvme/host/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3dd043aa6d1f..b3804dbdcc30 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1132,9 +1132,13 @@ static int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword
return ret;
}
+#define SET_NUMQ(nsqr, ncqr) (((nsqr) - 1) | (((ncqr) - 1) << 16))
+#define GET_NSQA(dw) (((dw) & 0xffff) + 1)
+#define GET_NCQA(dw) (((dw) >> 16) + 1)
+
int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count)
{
- u32 q_count = (*count - 1) | ((*count - 1) << 16);
+ u32 q_count = SET_NUMQ(*count, *count);
u32 result;
int status, nr_io_queues;
@@ -1152,7 +1156,7 @@ int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count)
dev_err(ctrl->device, "Could not set queue count (%d)\n", status);
*count = 0;
} else {
- nr_io_queues = min(result & 0xffff, result >> 16) + 1;
+ nr_io_queues = min(GET_NSQA(result), GET_NCQA(result));
*count = min(*count, nr_io_queues);
}
--
2.20.1
next prev parent reply other threads:[~2019-04-29 17:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-29 17:35 [PATCH 0/2] nvme: some cleanup Edmund Nadolski
2019-04-29 17:35 ` Edmund Nadolski [this message]
2019-04-29 23:21 ` [PATCH 1/2] nvme: nvme_set_queue_count should use descriptive macros Sagi Grimberg
2019-04-30 15:23 ` Christoph Hellwig
2019-04-29 17:35 ` [PATCH 2/2] nvme: add clarifying comments and fix some typos Edmund Nadolski
2019-04-29 23:23 ` Sagi Grimberg
2019-04-30 4:46 ` Edmund Nadolski
2019-04-29 23:32 ` Minwoo Im
2019-04-30 3:22 ` Chaitanya Kulkarni
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=20190429173533.10366-2-ednadols@linux.microsoft.com \
--to=ednadols@linux.microsoft.com \
/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