[RFC PATCH 02/21] loop: use lib tagset init helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 drivers/block/loop.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ad92192c7d61..a915f25b4410 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1937,6 +1937,8 @@ static const struct blk_mq_ops loop_mq_ops = {
 
 static int loop_add(int i)
 {
+	unsigned int flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_STACKING |
+		BLK_MQ_F_NO_SCHED_BY_DEFAULT;
 	struct loop_device *lo;
 	struct gendisk *disk;
 	int err;
@@ -1967,14 +1969,8 @@ static int loop_add(int i)
 		goto out_free_dev;
 	i = err;
 
-	lo->tag_set.ops = &loop_mq_ops;
-	lo->tag_set.nr_hw_queues = 1;
-	lo->tag_set.queue_depth = hw_queue_depth;
-	lo->tag_set.numa_node = NUMA_NO_NODE;
-	lo->tag_set.cmd_size = sizeof(struct loop_cmd);
-	lo->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_STACKING |
-		BLK_MQ_F_NO_SCHED_BY_DEFAULT;
-	lo->tag_set.driver_data = lo;
+	blk_mq_init_tag_set(&lo->tag_set, &loop_mq_ops, 1, hw_queue_depth,
+			sizeof(struct loop_cmd), NUMA_NO_NODE, 0, flags, lo);
 
 	err = blk_mq_alloc_tag_set(&lo->tag_set);
 	if (err)
-- 
2.29.0




[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux