[PATCH 2/6] nvme: add nvme_crd_msecs helper

Sagi Grimberg <[email protected]>
Newsgroups org.infradead.lists.linux-nvme
Message-ID <[email protected]>
Hide the details of extracting the crd value. We'll need it from other
call-sites.

Signed-off-by: Sagi Grimberg <[email protected]>
---
 drivers/nvme/host/core.c |  8 +-------
 drivers/nvme/host/nvme.h | 10 ++++++++++
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 453c1f0b2dd0..a49a86f96dd6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -321,15 +321,9 @@ static blk_status_t nvme_error_status(u16 status)
 
 static void nvme_retry_req(struct request *req)
 {
-	unsigned long delay = 0;
-	u16 crd;
+	unsigned long delay = nvme_crd_msecs(nvme_req(req));
 	struct nvme_ns *ns = req->q->queuedata;
 
-	/* The mask and shift result must be <= 3 */
-	crd = (nvme_req(req)->status & NVME_STATUS_CRD) >> 11;
-	if (crd)
-		delay = nvme_req(req)->ctrl->crdt[crd - 1] * 100;
-
 	nvme_req(req)->retries++;
 	if (ns)
 		atomic_long_inc(&ns->retries);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 824651cc898d..6d8f6c541a61 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -921,6 +921,16 @@ static inline enum req_op nvme_req_op(struct nvme_command *cmd)
 	return nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
 }
 
+static inline unsigned long nvme_crd_msecs(struct nvme_request *req)
+{
+	/* The mask and shift result must be <= 3 */
+	u16 crd = (req->status & NVME_STATUS_CRD) >> 11;
+
+	if (!crd)
+		return 0;
+	return req->ctrl->crdt[crd - 1] * 100;
+}
+
 #define NVME_QID_ANY -1
 void nvme_init_request(struct request *req, struct nvme_command *cmd);
 void nvme_cleanup_cmd(struct request *req);
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.