From: Christoph Hellwig Date: Mon, 6 Jun 2016 21:20:49 +0000 (+0200) Subject: nvme: factor out a add nvme_is_write helper X-Git-Tag: v4.1.12-102.0.20170601_1400~54 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9f53dfde7af14df40608f755dfd9b1d7749e4e43;p=users%2Fjedix%2Flinux-maple.git nvme: factor out a add nvme_is_write helper Centralize the check if a given NVMe command reads or writes data. Reviewed-by: Sagi Grimberg Reviewed-by: Jay Freyensee Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch Signed-off-by: Jens Axboe (cherry picked from commit 7a5abb4b48570c3552e33ff4c72ae1e8dac3ba15) Orabug: 25130845 Signed-off-by: Ashok Vairavan Reviewed-by: Martin K. Petersen --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index bd1acb8d0e6bc..bf1dc39538045 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -195,10 +195,9 @@ EXPORT_SYMBOL_GPL(nvme_requeue_req); struct request *nvme_alloc_request(struct request_queue *q, struct nvme_command *cmd, unsigned int flags) { - bool write = cmd->common.opcode & 1; struct request *req; - req = blk_mq_alloc_request(q, write, GFP_ATOMIC, 0); + req = blk_mq_alloc_request(q, nvme_is_write(cmd), GFP_ATOMIC, 0); if (IS_ERR(req)) return req; @@ -363,7 +362,7 @@ int __nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd, void __user *meta_buffer, unsigned meta_len, u32 meta_seed, u32 *result, unsigned timeout) { - bool write = cmd->common.opcode & 1; + bool write = nvme_is_write(cmd); struct nvme_completion cqe; struct nvme_ns *ns = q->queuedata; struct gendisk *disk = ns ? ns->disk : NULL; diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 2b82f05fe4ecf..dc815cc6718db 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -590,6 +590,11 @@ struct nvme_command { }; }; +static inline bool nvme_is_write(struct nvme_command *cmd) +{ + return cmd->common.opcode & 1; +} + enum { NVME_SC_SUCCESS = 0x0, NVME_SC_INVALID_OPCODE = 0x1,