diff mbox series

[RFC,20/21] nvme-apple: use lib tagset init helper

Message ID 20221005032257.80681-21-kch@nvidia.com (mailing list archive)
State Not Applicable
Headers show
Series block: add and use init tagset helper | expand

Commit Message

Chaitanya Kulkarni Oct. 5, 2022, 3:22 a.m. UTC
Use the block layer helper to initialize the common fields of tag_set
such as blk_mq_ops, number of h/w queues, queue depth, command size,
numa_node, timeout, BLK_MQ_F_XXX flags, driver data. This initialization
is spread all over the block drivers. This avoids the code repetation of
the inialization code of the tag set in current block drivers and any
future ones.

Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
---
 drivers/nvme/host/apple.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/drivers/nvme/host/apple.c b/drivers/nvme/host/apple.c
index 5fc5ea196b40..bc95c3d93c57 100644
--- a/drivers/nvme/host/apple.c
+++ b/drivers/nvme/host/apple.c
@@ -1228,15 +1228,10 @@  static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
 {
 	int ret;
 
-	anv->admin_tagset.ops = &apple_nvme_mq_admin_ops;
-	anv->admin_tagset.nr_hw_queues = 1;
-	anv->admin_tagset.queue_depth = APPLE_NVME_AQ_MQ_TAG_DEPTH;
-	anv->admin_tagset.timeout = NVME_ADMIN_TIMEOUT;
-	anv->admin_tagset.numa_node = NUMA_NO_NODE;
-	anv->admin_tagset.cmd_size = sizeof(struct apple_nvme_iod);
-	anv->admin_tagset.flags = BLK_MQ_F_NO_SCHED;
-	anv->admin_tagset.driver_data = &anv->adminq;
-
+	blk_mq_init_tag_set(&anv->admin_tagset, &apple_nvme_mq_admin_ops, 1,
+			APPLE_NVME_AQ_MQ_TAG_DEPTH, sizeof(struct apple_nvme_iod),
+			NUMA_NO_NODE, NVME_ADMIN_TIMEOUT, BLK_MQ_F_NO_SCHED,
+			&anv->adminq);
 	ret = blk_mq_alloc_tag_set(&anv->admin_tagset);
 	if (ret)
 		return ret;
@@ -1245,8 +1240,6 @@  static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
 	if (ret)
 		return ret;
 
-	anv->tagset.ops = &apple_nvme_mq_ops;
-	anv->tagset.nr_hw_queues = 1;
 	anv->tagset.nr_maps = 1;
 	/*
 	 * Tags are used as an index to the NVMMU and must be unique across
@@ -1254,13 +1247,11 @@  static int apple_nvme_alloc_tagsets(struct apple_nvme *anv)
 	 * must be marked as reserved in the IO queue.
 	 */
 	anv->tagset.reserved_tags = APPLE_NVME_AQ_DEPTH;
-	anv->tagset.queue_depth = APPLE_ANS_MAX_QUEUE_DEPTH - 1;
-	anv->tagset.timeout = NVME_IO_TIMEOUT;
-	anv->tagset.numa_node = NUMA_NO_NODE;
-	anv->tagset.cmd_size = sizeof(struct apple_nvme_iod);
-	anv->tagset.flags = BLK_MQ_F_SHOULD_MERGE;
-	anv->tagset.driver_data = &anv->ioq;
 
+	blk_mq_init_tag_set(&anv->admin_tagset, &apple_nvme_mq_admin_ops, 1,
+			APPLE_ANS_MAX_QUEUE_DEPTH - 1, sizeof(struct apple_nvme_iod),
+			NUMA_NO_NODE, NVME_IO_TIMEOUT, BLK_MQ_F_SHOULD_MERGE,
+			&anv->ioq);
 	ret = blk_mq_alloc_tag_set(&anv->tagset);
 	if (ret)
 		return ret;