Commit 9c8463e8 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

swim3: 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-12-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 89662ac5
...@@ -1202,30 +1202,27 @@ static int swim3_attach(struct macio_dev *mdev, ...@@ -1202,30 +1202,27 @@ static int swim3_attach(struct macio_dev *mdev,
return rc; return rc;
} }
disk = alloc_disk(1);
if (disk == NULL) {
rc = -ENOMEM;
goto out_unregister;
}
fs = &floppy_states[floppy_count]; fs = &floppy_states[floppy_count];
memset(fs, 0, sizeof(*fs)); memset(fs, 0, sizeof(*fs));
disk->queue = blk_mq_init_sq_queue(&fs->tag_set, &swim3_mq_ops, 2, rc = blk_mq_alloc_sq_tag_set(&fs->tag_set, &swim3_mq_ops, 2,
BLK_MQ_F_SHOULD_MERGE); BLK_MQ_F_SHOULD_MERGE);
if (IS_ERR(disk->queue)) { if (rc)
rc = PTR_ERR(disk->queue); goto out_unregister;
disk->queue = NULL;
goto out_put_disk; disk = blk_mq_alloc_disk(&fs->tag_set, fs);
if (IS_ERR(disk)) {
rc = PTR_ERR(disk);
goto out_free_tag_set;
} }
disk->queue->queuedata = fs;
rc = swim3_add_device(mdev, floppy_count); rc = swim3_add_device(mdev, floppy_count);
if (rc) if (rc)
goto out_cleanup_queue; goto out_cleanup_disk;
disk->major = FLOPPY_MAJOR; disk->major = FLOPPY_MAJOR;
disk->first_minor = floppy_count; disk->first_minor = floppy_count;
disk->minors = 1;
disk->fops = &floppy_fops; disk->fops = &floppy_fops;
disk->private_data = fs; disk->private_data = fs;
disk->events = DISK_EVENT_MEDIA_CHANGE; disk->events = DISK_EVENT_MEDIA_CHANGE;
...@@ -1237,12 +1234,10 @@ static int swim3_attach(struct macio_dev *mdev, ...@@ -1237,12 +1234,10 @@ static int swim3_attach(struct macio_dev *mdev,
disks[floppy_count++] = disk; disks[floppy_count++] = disk;
return 0; return 0;
out_cleanup_queue: out_cleanup_disk:
blk_cleanup_queue(disk->queue); blk_cleanup_disk(disk);
disk->queue = NULL; out_free_tag_set:
blk_mq_free_tag_set(&fs->tag_set); blk_mq_free_tag_set(&fs->tag_set);
out_put_disk:
put_disk(disk);
out_unregister: out_unregister:
if (floppy_count == 0) if (floppy_count == 0)
unregister_blkdev(FLOPPY_MAJOR, "fd"); unregister_blkdev(FLOPPY_MAJOR, "fd");
......
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