From: Ming Lin Date: Mon, 25 Apr 2016 21:33:20 +0000 (-0700) Subject: nvme: add helper nvme_cleanup_cmd() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=6904242db1ac07403c331b18796f6c2bf5382aec;p=linux-beck.git nvme: add helper nvme_cleanup_cmd() This hides command cleanup into nvme.h and fabrics drivers will also use it. Signed-off-by: Ming Lin Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe --- diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 631a11e15b7c..114b92873894 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -182,6 +182,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) { diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 82a0fc200f44..077e9bf6a1b8 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -321,8 +321,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);