diff mbox series

[for-next,v11,13/13] nvme: Use blk_rq_map_user_io helper

Message ID 20220929120632.64749-14-anuj20.g@samsung.com (mailing list archive)
State New, archived
Headers show
Series [for-next,v11,01/13] io_uring: add io_uring_cmd_import_fixed | expand

Commit Message

Anuj Gupta Sept. 29, 2022, 12:06 p.m. UTC
User blk_rq_map_user_io instead of duplicating the same code at
different places

Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
---
 drivers/nvme/host/ioctl.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 25a68e8c60db..a3f22bbe511a 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -106,21 +106,12 @@  static int nvme_map_user_request(struct request *req, u64 ubuffer,
 		if (ret < 0)
 			goto out;
 		ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
-	} else if (vec) {
-		struct iovec fast_iov[UIO_FASTIOV];
-		struct iovec *iov = fast_iov;
-		struct iov_iter iter;
-
-		ret = import_iovec(rq_data_dir(req), nvme_to_user_ptr(ubuffer),
-				bufflen, UIO_FASTIOV, &iov, &iter);
-		if (ret < 0)
-			goto out;
-		ret = blk_rq_map_user_iov(q, req, NULL, &iter, GFP_KERNEL);
-		kfree(iov);
 	} else {
-		ret = blk_rq_map_user(q, req, NULL,
-				nvme_to_user_ptr(ubuffer), bufflen, GFP_KERNEL);
+		ret = blk_rq_map_user_io(req, NULL, nvme_to_user_ptr(ubuffer),
+				bufflen, GFP_KERNEL, vec, 0, 0,
+				rq_data_dir(req));
 	}
+
 	if (ret)
 		goto out;
 	bio = req->bio;