swim3: use blk_mq_alloc_disk
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-12-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Родитель
89662ac55a
Коммит
9c8463e8e1
|
@ -1202,30 +1202,27 @@ static int swim3_attach(struct macio_dev *mdev,
|
|||
return rc;
|
||||
}
|
||||
|
||||
disk = alloc_disk(1);
|
||||
if (disk == NULL) {
|
||||
rc = -ENOMEM;
|
||||
goto out_unregister;
|
||||
}
|
||||
|
||||
fs = &floppy_states[floppy_count];
|
||||
memset(fs, 0, sizeof(*fs));
|
||||
|
||||
disk->queue = blk_mq_init_sq_queue(&fs->tag_set, &swim3_mq_ops, 2,
|
||||
BLK_MQ_F_SHOULD_MERGE);
|
||||
if (IS_ERR(disk->queue)) {
|
||||
rc = PTR_ERR(disk->queue);
|
||||
disk->queue = NULL;
|
||||
goto out_put_disk;
|
||||
rc = blk_mq_alloc_sq_tag_set(&fs->tag_set, &swim3_mq_ops, 2,
|
||||
BLK_MQ_F_SHOULD_MERGE);
|
||||
if (rc)
|
||||
goto out_unregister;
|
||||
|
||||
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);
|
||||
if (rc)
|
||||
goto out_cleanup_queue;
|
||||
goto out_cleanup_disk;
|
||||
|
||||
disk->major = FLOPPY_MAJOR;
|
||||
disk->first_minor = floppy_count;
|
||||
disk->minors = 1;
|
||||
disk->fops = &floppy_fops;
|
||||
disk->private_data = fs;
|
||||
disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
|
@ -1237,12 +1234,10 @@ static int swim3_attach(struct macio_dev *mdev,
|
|||
disks[floppy_count++] = disk;
|
||||
return 0;
|
||||
|
||||
out_cleanup_queue:
|
||||
blk_cleanup_queue(disk->queue);
|
||||
disk->queue = NULL;
|
||||
out_cleanup_disk:
|
||||
blk_cleanup_disk(disk);
|
||||
out_free_tag_set:
|
||||
blk_mq_free_tag_set(&fs->tag_set);
|
||||
out_put_disk:
|
||||
put_disk(disk);
|
||||
out_unregister:
|
||||
if (floppy_count == 0)
|
||||
unregister_blkdev(FLOPPY_MAJOR, "fd");
|
||||
|
|
Загрузка…
Ссылка в новой задаче