Commit 51fbfedf authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

swim: use blk_mq_alloc_disk

Use the blk_mq_alloc_disk API to simplify the gendisk and request_queue
allocation.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Link: https://lore.kernel.org/r/20210602065345.355274-13-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 9c8463e8
...@@ -800,23 +800,20 @@ static int swim_floppy_init(struct swim_priv *swd) ...@@ -800,23 +800,20 @@ static int swim_floppy_init(struct swim_priv *swd)
spin_lock_init(&swd->lock); spin_lock_init(&swd->lock);
for (drive = 0; drive < swd->floppy_count; drive++) { for (drive = 0; drive < swd->floppy_count; drive++) {
struct request_queue *q; err = blk_mq_alloc_sq_tag_set(&swd->unit[drive].tag_set,
&swim_mq_ops, 2, BLK_MQ_F_SHOULD_MERGE);
swd->unit[drive].disk = alloc_disk(1); if (err)
if (swd->unit[drive].disk == NULL) {
err = -ENOMEM;
goto exit_put_disks; goto exit_put_disks;
}
q = blk_mq_init_sq_queue(&swd->unit[drive].tag_set, &swim_mq_ops, swd->unit[drive].disk =
2, BLK_MQ_F_SHOULD_MERGE); blk_mq_alloc_disk(&swd->unit[drive].tag_set,
if (IS_ERR(q)) { &swd->unit[drive]);
err = PTR_ERR(q); if (IS_ERR(swd->unit[drive].disk)) {
blk_mq_free_tag_set(&swd->unit[drive].tag_set);
err = PTR_ERR(swd->unit[drive].disk);
goto exit_put_disks; goto exit_put_disks;
} }
swd->unit[drive].disk->queue = q;
swd->unit[drive].disk->queue->queuedata = &swd->unit[drive];
swd->unit[drive].swd = swd; swd->unit[drive].swd = swd;
} }
...@@ -824,6 +821,7 @@ static int swim_floppy_init(struct swim_priv *swd) ...@@ -824,6 +821,7 @@ static int swim_floppy_init(struct swim_priv *swd)
swd->unit[drive].disk->flags = GENHD_FL_REMOVABLE; swd->unit[drive].disk->flags = GENHD_FL_REMOVABLE;
swd->unit[drive].disk->major = FLOPPY_MAJOR; swd->unit[drive].disk->major = FLOPPY_MAJOR;
swd->unit[drive].disk->first_minor = drive; swd->unit[drive].disk->first_minor = drive;
swd->unit[drive].disk->minors = 1;
sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive);
swd->unit[drive].disk->fops = &floppy_fops; swd->unit[drive].disk->fops = &floppy_fops;
swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE; swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE;
...@@ -839,14 +837,10 @@ static int swim_floppy_init(struct swim_priv *swd) ...@@ -839,14 +837,10 @@ static int swim_floppy_init(struct swim_priv *swd)
do { do {
struct gendisk *disk = swd->unit[drive].disk; struct gendisk *disk = swd->unit[drive].disk;
if (disk) { if (!disk)
if (disk->queue) { continue;
blk_cleanup_queue(disk->queue); blk_cleanup_disk(disk);
disk->queue = NULL; blk_mq_free_tag_set(&swd->unit[drive].tag_set);
}
blk_mq_free_tag_set(&swd->unit[drive].tag_set);
put_disk(disk);
}
} while (drive--); } while (drive--);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment