From: Valentine Fatiev <valentinef@nvidia.com>
Subject: [PATCH] BACKPORT: drivers/nvme/host/pr.c

Change-Id: Iea6f2efe62489c66af86e2076f7b81005dd5e041
---
 drivers/nvme/host/pr.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

--- a/drivers/nvme/host/pr.c
+++ b/drivers/nvme/host/pr.c
@@ -29,6 +29,7 @@ static enum nvme_pr_type nvme_pr_type_fr
 	return 0;
 }
 
+#ifdef HAVE_PR_KEYS
 static enum pr_type block_pr_type_from_nvme(enum nvme_pr_type type)
 {
 	switch (type) {
@@ -48,6 +49,7 @@ static enum pr_type block_pr_type_from_n
 
 	return 0;
 }
+#endif
 
 static int nvme_send_ns_head_pr_command(struct block_device *bdev,
 		struct nvme_command *c, void *data, unsigned int data_len)
@@ -72,6 +74,7 @@ static int nvme_send_ns_pr_command(struc
 	return nvme_submit_sync_cmd(ns->queue, c, data, data_len);
 }
 
+#ifdef HAVE_PR_STATUS
 static int nvme_sc_to_pr_err(int nvme_sc)
 {
 	if (nvme_is_path_error(nvme_sc))
@@ -93,6 +96,7 @@ static int nvme_sc_to_pr_err(int nvme_sc
 		return PR_STS_IOERR;
 	}
 }
+#endif
 
 static int nvme_send_pr_command(struct block_device *bdev,
 		struct nvme_command *c, void *data, unsigned int data_len)
@@ -118,10 +122,14 @@ static int nvme_pr_command(struct block_
 	c.common.cdw10 = cpu_to_le32(cdw10);
 
 	ret = nvme_send_pr_command(bdev, &c, data, sizeof(data));
+#ifdef HAVE_PR_STATUS
 	if (ret < 0)
 		return ret;
 
 	return nvme_sc_to_pr_err(ret);
+#else
+	return ret;
+#endif
 }
 
 static int nvme_pr_register(struct block_device *bdev, u64 old,
@@ -173,6 +181,7 @@ static int nvme_pr_release(struct block_
 	return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
 }
 
+#ifdef HAVE_PR_KEYS
 static int nvme_pr_resv_report(struct block_device *bdev, void *data,
 		u32 data_len, bool *eds)
 {
@@ -193,10 +202,14 @@ retry:
 		goto retry;
 	}
 
+#ifdef HAVE_PR_STATUS
 	if (ret < 0)
 		return ret;
 
 	return nvme_sc_to_pr_err(ret);
+#else
+	return ret;
+#endif
 }
 
 static int nvme_pr_read_keys(struct block_device *bdev,
@@ -302,6 +315,7 @@ free_rse:
 	kfree(rse);
 	return ret;
 }
+#endif
 
 const struct pr_ops nvme_pr_ops = {
 	.pr_register	= nvme_pr_register,
@@ -309,6 +323,8 @@ const struct pr_ops nvme_pr_ops = {
 	.pr_release	= nvme_pr_release,
 	.pr_preempt	= nvme_pr_preempt,
 	.pr_clear	= nvme_pr_clear,
+#ifdef HAVE_PR_KEYS
 	.pr_read_keys	= nvme_pr_read_keys,
 	.pr_read_reservation = nvme_pr_read_reservation,
+#endif
 };
