[PATCH 1/2] nvme-core: cleanup nvme_pr_type()

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Thu Oct 29 14:59:57 EDT 2020


The switch in the nvme_pr_type() returns values which can be mapped 1:1
on the PR_XXX macors. Get rid of the long switch and replace with simple
conditional operator to return the value.

This is purely code cleanup and doesn't change any functionality.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/host/core.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 376096bfc54a..16f590a03486 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2149,23 +2149,11 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 
 static char nvme_pr_type(enum pr_type type)
 {
-	switch (type) {
-	case PR_WRITE_EXCLUSIVE:
-		return 1;
-	case PR_EXCLUSIVE_ACCESS:
-		return 2;
-	case PR_WRITE_EXCLUSIVE_REG_ONLY:
-		return 3;
-	case PR_EXCLUSIVE_ACCESS_REG_ONLY:
-		return 4;
-	case PR_WRITE_EXCLUSIVE_ALL_REGS:
-		return 5;
-	case PR_EXCLUSIVE_ACCESS_ALL_REGS:
-		return 6;
-	default:
+	if (type < PR_WRITE_EXCLUSIVE || type > PR_EXCLUSIVE_ACCESS_ALL_REGS)
 		return 0;
-	}
-};
+
+	return type;
+}
 
 static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
 				u64 key, u64 sa_key, u8 op)
-- 
2.22.1




More information about the Linux-nvme mailing list