pf: use blk_mq_alloc_disk
authorChristoph Hellwig <hch@lst.de>
Wed, 2 Jun 2021 06:53:21 +0000 (09:53 +0300)
committerJens Axboe <axboe@kernel.dk>
Fri, 11 Jun 2021 17:53:02 +0000 (11:53 -0600)
Use the blk_mq_alloc_disk API to simplify the gendisk and request_queue
allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210602065345.355274-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/paride/pf.c

index bb09f21..d5b9c88 100644 (file)
@@ -294,20 +294,17 @@ static void __init pf_init_units(void)
        for (unit = 0, pf = units; unit < PF_UNITS; unit++, pf++) {
                struct gendisk *disk;
 
-               disk = alloc_disk(1);
-               if (!disk)
+               if (blk_mq_alloc_sq_tag_set(&pf->tag_set, &pf_mq_ops, 1,
+                               BLK_MQ_F_SHOULD_MERGE))
                        continue;
 
-               disk->queue = blk_mq_init_sq_queue(&pf->tag_set, &pf_mq_ops,
-                                                       1, BLK_MQ_F_SHOULD_MERGE);
-               if (IS_ERR(disk->queue)) {
-                       disk->queue = NULL;
-                       put_disk(disk);
+               disk = blk_mq_alloc_disk(&pf->tag_set, pf);
+               if (IS_ERR(disk)) {
+                       blk_mq_free_tag_set(&pf->tag_set);
                        continue;
                }
 
                INIT_LIST_HEAD(&pf->rq_list);
-               disk->queue->queuedata = pf;
                blk_queue_max_segments(disk->queue, cluster);
                blk_queue_bounce_limit(disk->queue, BLK_BOUNCE_HIGH);
                pf->disk = disk;
@@ -318,6 +315,7 @@ static void __init pf_init_units(void)
                snprintf(pf->name, PF_NAMELEN, "%s%d", name, unit);
                disk->major = major;
                disk->first_minor = unit;
+               disk->minors = 1;
                strcpy(disk->disk_name, pf->name);
                disk->fops = &pf_fops;
                disk->events = DISK_EVENT_MEDIA_CHANGE;
@@ -766,10 +764,8 @@ static int pf_detect(void)
        for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) {
                if (!pf->disk)
                        continue;
-               blk_cleanup_queue(pf->disk->queue);
-               pf->disk->queue = NULL;
+               blk_cleanup_disk(pf->disk);
                blk_mq_free_tag_set(&pf->tag_set);
-               put_disk(pf->disk);
        }
        pi_unregister_driver(par_drv);
        return -1;