]> www.infradead.org Git - nvme.git/commitdiff
nvmet: Use enum definitions instead of hardcoded values
authorDamien Le Moal <dlemoal@kernel.org>
Thu, 13 Feb 2025 06:50:00 +0000 (15:50 +0900)
committerKeith Busch <kbusch@kernel.org>
Tue, 18 Feb 2025 15:39:42 +0000 (07:39 -0800)
Change the definition of the inline functions nvmet_cc_en(),
nvmet_cc_css(), nvmet_cc_mps(), nvmet_cc_ams(), nvmet_cc_shn(),
nvmet_cc_iosqes(), and nvmet_cc_iocqes() to use the enum difinitions in
include/linux/nvme.h instead of hardcoded values.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/nvmet.h

index 4be8d22d2d8d417b0eb285a35b7d51cf5be23bdd..d2c1233981e1a12f5f24ab4aead21afaec5c00f4 100644 (file)
@@ -784,37 +784,37 @@ u16 nvmet_report_invalid_opcode(struct nvmet_req *req);
 
 static inline bool nvmet_cc_en(u32 cc)
 {
-       return (cc >> NVME_CC_EN_SHIFT) & 0x1;
+       return (cc & NVME_CC_ENABLE) >> NVME_CC_EN_SHIFT;
 }
 
 static inline u8 nvmet_cc_css(u32 cc)
 {
-       return (cc >> NVME_CC_CSS_SHIFT) & 0x7;
+       return (cc & NVME_CC_CSS_MASK) >> NVME_CC_CSS_SHIFT;
 }
 
 static inline u8 nvmet_cc_mps(u32 cc)
 {
-       return (cc >> NVME_CC_MPS_SHIFT) & 0xf;
+       return (cc & NVME_CC_MPS_MASK) >> NVME_CC_MPS_SHIFT;
 }
 
 static inline u8 nvmet_cc_ams(u32 cc)
 {
-       return (cc >> NVME_CC_AMS_SHIFT) & 0x7;
+       return (cc & NVME_CC_AMS_MASK) >> NVME_CC_AMS_SHIFT;
 }
 
 static inline u8 nvmet_cc_shn(u32 cc)
 {
-       return (cc >> NVME_CC_SHN_SHIFT) & 0x3;
+       return (cc & NVME_CC_SHN_MASK) >> NVME_CC_SHN_SHIFT;
 }
 
 static inline u8 nvmet_cc_iosqes(u32 cc)
 {
-       return (cc >> NVME_CC_IOSQES_SHIFT) & 0xf;
+       return (cc & NVME_CC_IOSQES_MASK) >> NVME_CC_IOSQES_SHIFT;
 }
 
 static inline u8 nvmet_cc_iocqes(u32 cc)
 {
-       return (cc >> NVME_CC_IOCQES_SHIFT) & 0xf;
+       return (cc & NVME_CC_IOCQES_MASK) >> NVME_CC_IOCQES_SHIFT;
 }
 
 /* Convert a 32-bit number to a 16-bit 0's based number */