[PATCH v2 08/20] nvme: Add helper to convert to a pr_ops PR type

Mike Christie
2022-08-09T00:06:53Z

This adds a helper to go from the NVMe spec PR type value to the block
layer pr_type, so for Reservation Report support we can convert from its
value.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
drivers/nvme/host/core.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3f223641f321..0dc768ae0c16 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2064,6 +2064,26 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
}
}

+static enum pr_type block_pr_type(u8 nvme_type)
+{
+ switch (nvme_type) {
+ case 1:
+ return PR_WRITE_EXCLUSIVE;
+ case 2:
+ return PR_EXCLUSIVE_ACCESS;
+ case 3:
+ return PR_WRITE_EXCLUSIVE_REG_ONLY;
+ case 4:
+ return PR_EXCLUSIVE_ACCESS_REG_ONLY;
+ case 5:
+ return PR_WRITE_EXCLUSIVE_ALL_REGS;
+ case 6:
+ return PR_EXCLUSIVE_ACCESS_ALL_REGS;
+ default:
+ return 0;
+ }
+}
+
static char nvme_pr_type(enum pr_type type)
{
switch (type) {
--
2.18.2