gdrom: 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-15-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
afea05a18d
commit
0592c3d166
@ -772,53 +772,50 @@ static int probe_gdrom(struct platform_device *devptr)
|
||||
goto probe_fail_no_mem;
|
||||
}
|
||||
probe_gdrom_setupcd();
|
||||
gd.disk = alloc_disk(1);
|
||||
if (!gd.disk) {
|
||||
err = -ENODEV;
|
||||
goto probe_fail_no_disk;
|
||||
|
||||
err = blk_mq_alloc_sq_tag_set(&gd.tag_set, &gdrom_mq_ops, 1,
|
||||
BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING);
|
||||
if (err)
|
||||
goto probe_fail_free_cd_info;
|
||||
|
||||
gd.disk = blk_mq_alloc_disk(&gd.tag_set, NULL);
|
||||
if (IS_ERR(gd.disk)) {
|
||||
err = PTR_ERR(gd.disk);
|
||||
goto probe_fail_free_tag_set;
|
||||
}
|
||||
gd.gdrom_rq = gd.disk->queue;
|
||||
probe_gdrom_setupdisk();
|
||||
if (register_cdrom(gd.disk, gd.cd_info)) {
|
||||
err = -ENODEV;
|
||||
goto probe_fail_cdrom_register;
|
||||
goto probe_fail_cleanup_disk;
|
||||
}
|
||||
gd.disk->fops = &gdrom_bdops;
|
||||
gd.disk->events = DISK_EVENT_MEDIA_CHANGE;
|
||||
/* latch on to the interrupt */
|
||||
err = gdrom_set_interrupt_handlers();
|
||||
if (err)
|
||||
goto probe_fail_cmdirq_register;
|
||||
|
||||
gd.gdrom_rq = blk_mq_init_sq_queue(&gd.tag_set, &gdrom_mq_ops, 1,
|
||||
BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING);
|
||||
if (IS_ERR(gd.gdrom_rq)) {
|
||||
err = PTR_ERR(gd.gdrom_rq);
|
||||
gd.gdrom_rq = NULL;
|
||||
goto probe_fail_requestq;
|
||||
}
|
||||
goto probe_fail_cleanup_disk;
|
||||
|
||||
err = probe_gdrom_setupqueue();
|
||||
if (err)
|
||||
goto probe_fail_toc;
|
||||
goto probe_fail_free_irqs;
|
||||
|
||||
gd.toc = kzalloc(sizeof(struct gdromtoc), GFP_KERNEL);
|
||||
if (!gd.toc) {
|
||||
err = -ENOMEM;
|
||||
goto probe_fail_toc;
|
||||
goto probe_fail_free_irqs;
|
||||
}
|
||||
add_disk(gd.disk);
|
||||
return 0;
|
||||
|
||||
probe_fail_toc:
|
||||
blk_cleanup_queue(gd.gdrom_rq);
|
||||
blk_mq_free_tag_set(&gd.tag_set);
|
||||
probe_fail_requestq:
|
||||
probe_fail_free_irqs:
|
||||
free_irq(HW_EVENT_GDROM_DMA, &gd);
|
||||
free_irq(HW_EVENT_GDROM_CMD, &gd);
|
||||
probe_fail_cmdirq_register:
|
||||
probe_fail_cdrom_register:
|
||||
del_gendisk(gd.disk);
|
||||
probe_fail_no_disk:
|
||||
probe_fail_cleanup_disk:
|
||||
blk_cleanup_disk(gd.disk);
|
||||
probe_fail_free_tag_set:
|
||||
blk_mq_free_tag_set(&gd.tag_set);
|
||||
probe_fail_free_cd_info:
|
||||
kfree(gd.cd_info);
|
||||
probe_fail_no_mem:
|
||||
unregister_blkdev(gdrom_major, GDROM_DEV_NAME);
|
||||
|
Loading…
Reference in New Issue
Block a user