Skip to contentSkip to conversation

nvme: add helper nvme_cleanup_cmd()

PATCH New Ming Lin 5 participants 5 messages Apr 25, 2016 – May 2, 2016 NVMe

lore
Share & tools
lore

Ming Lin

author
#0 lore raw

PATCH v2 1/1 nvme: add helper nvme_cleanup_cmd()

From: Ming Lin <[email protected]>

This hides command cleanup into nvme.h and fabrics drivers will also use it.

Signed-off-by Ming Lin <ming.l at ssi.samsung.com>
---
 drivers/nvme/host/nvme.h | 6 ++++++
 drivers/nvme/host/pci.c  | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)

v2:
- make this a static inline in nvme.h

drivers/nvme/host/nvme.h +6 -0
index 8e8fae8..8c363ab 100644
@@ -181,6 +181,12 @@ static inline unsigned nvme_map_len(struct request *rq)
 		return blk_rq_bytes(rq);
 }
 
+static inline void nvme_cleanup_cmd(struct request *req)
+{
+	if (req->cmd_flags & REQ_DISCARD)
+		kfree(req->completion_data);
+}
+
 static inline int nvme_error_status(u16 status)
 {
 	switch (status & 0x7ff) {
drivers/nvme/host/pci.c +1 -2
index ff3c8d7..0569cbf 100644
@@ -363,8 +363,7 @@ static void nvme_free_iod(struct nvme_dev *dev, struct request *req)
 	__le64 **list = iod_list(req);
 	dma_addr_t prp_dma = iod->first_dma;
 
-	if (req->cmd_flags & REQ_DISCARD)
-		kfree(req->completion_data);
+	nvme_cleanup_cmd(req);
 
 	if (iod->npages == 0)
 		dma_pool_free(dev->prp_small_pool, list[0], prp_dma);
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 nvme: add helper nvme_cleanup_cmd()

Quoted 6 lines · Ming Lin

From: Ming Lin <ming.l at ssi.samsung.com>

This hides command cleanup into nvme.h and fabrics drivers will also use it.

Signed-off-by Ming Lin <ming.l at ssi.samsung.com>

Looks good.

Reviewed-by Keith Busch <keith.busch at intel.com>
maintainer
#4 lore raw

PATCH v2 1/1 nvme: add helper nvme_cleanup_cmd()

In reply to Ming Lin
Quoted 4 lines · Ming Lin

From: Ming Lin <ming.l at ssi.samsung.com>

This hides command cleanup into nvme.h and fabrics drivers will also use it.

Added to 4.7.

Signature · 1 line
Jens Axboe