nvme: some cleanup
v2 cover nvme: some cleanup
This series clarifies the code intent by adding some macros and fixing a few miscellaneous typos.
v2 changes:
- Move typo fixes into separate patch.
- Drop struct member comments.
- Clarify changelog remarks.
Edmund Nadolski (2):
nvme: nvme_set_queue_count should use descriptive macros
nvme: fix some typos
drivers/nvme/host/core.c | 8 ++++++-- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/2 nvme: nvme_set_queue_count should use descriptive macros
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 and reflects the field names used in the spec.
--- drivers/nvme/host/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +6 -2
@@ -1132,9 +1132,13 @@ static int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dwordreturn 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); }
Signature · 1 line
2.20.1
PATCH v2 1/2 nvme: nvme_set_queue_count should use descriptive macros
Quoted 29 lines · Edmund Nadolski
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 and reflects the field names used in the spec.
Signed-off-by Edmund Nadolski <ednadols at linux.microsoft.com>--- drivers/nvme/host/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/nvme/host/core.c +5
-1@@ -1132,9 +1132,13 @@ static int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dwordreturn 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;
drivers/nvme/host/core.c int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count) · line 1162
Quoted 8 lines
drivers/nvme/host/core.c +1
-1@@ -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); }
I agree with Christoph. I think it actually hurts understanding.
-- james
PATCH v2 2/2 nvme: fix some typos
In reply to Edmund NadolskiCorrects a few trivial typos.
--- drivers/nvme/host/nvme.h | 2 +- drivers/nvme/host/pci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/nvme.h +1 -1
@@ -290,7 +290,7 @@ struct nvme_ns_ids {/* * Anchor structure for namespaces. There is one for each namespace in a * NVMe subsystem that any of our controllers can see, and the namespace -* structure for each controller is chained of it. For private namespaces +* structure for each controller is chained off it. For private namespaces * there is a 1:1 relation to our namespace structures, that is ->list * only ever has a single entry for private namespaces. */
drivers/nvme/host/pci.c +1 -1
@@ -227,7 +227,7 @@ struct nvme_iod { };/* -* Check we didin't inadvertently grow the command struct +* Check we didn't inadvertently grow the command struct */ static inline void _nvme_check_size (void ) {
Signature · 1 line
2.20.1