Commit 34f84aef authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

floppy: use blk_mq_alloc_disk and blk_cleanup_disk

Use blk_mq_alloc_disk and blk_cleanup_disk 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-18-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6560ec96
...@@ -4491,23 +4491,15 @@ static bool floppy_available(int drive) ...@@ -4491,23 +4491,15 @@ static bool floppy_available(int drive)
static int floppy_alloc_disk(unsigned int drive, unsigned int type) static int floppy_alloc_disk(unsigned int drive, unsigned int type)
{ {
struct gendisk *disk; struct gendisk *disk;
int err;
disk = alloc_disk(1);
if (!disk)
return -ENOMEM;
disk->queue = blk_mq_init_queue(&tag_sets[drive]); disk = blk_mq_alloc_disk(&tag_sets[drive], NULL);
if (IS_ERR(disk->queue)) { if (IS_ERR(disk))
err = PTR_ERR(disk->queue); return PTR_ERR(disk);
disk->queue = NULL;
put_disk(disk);
return err;
}
blk_queue_max_hw_sectors(disk->queue, 64); blk_queue_max_hw_sectors(disk->queue, 64);
disk->major = FLOPPY_MAJOR; disk->major = FLOPPY_MAJOR;
disk->first_minor = TOMINOR(drive) | (type << 2); disk->first_minor = TOMINOR(drive) | (type << 2);
disk->minors = 1;
disk->fops = &floppy_fops; disk->fops = &floppy_fops;
disk->events = DISK_EVENT_MEDIA_CHANGE; disk->events = DISK_EVENT_MEDIA_CHANGE;
if (type) if (type)
...@@ -4727,10 +4719,8 @@ static int __init do_floppy_init(void) ...@@ -4727,10 +4719,8 @@ static int __init do_floppy_init(void)
if (!disks[drive][0]) if (!disks[drive][0])
break; break;
del_timer_sync(&motor_off_timer[drive]); del_timer_sync(&motor_off_timer[drive]);
blk_cleanup_queue(disks[drive][0]->queue); blk_cleanup_disk(disks[drive][0]);
disks[drive][0]->queue = NULL;
blk_mq_free_tag_set(&tag_sets[drive]); blk_mq_free_tag_set(&tag_sets[drive]);
put_disk(disks[drive][0]);
} }
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