mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 17:23:25 -05:00
ps3disk: 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> Tested-by: Geoff Levand <geoff@infradead.org> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210602065345.355274-11-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
6966bb921d
commit
89662ac55a
1 changed files with 14 additions and 22 deletions
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
struct ps3disk_private {
|
struct ps3disk_private {
|
||||||
spinlock_t lock; /* Request queue spinlock */
|
spinlock_t lock; /* Request queue spinlock */
|
||||||
struct request_queue *queue;
|
|
||||||
struct blk_mq_tag_set tag_set;
|
struct blk_mq_tag_set tag_set;
|
||||||
struct gendisk *gendisk;
|
struct gendisk *gendisk;
|
||||||
unsigned int blocking_factor;
|
unsigned int blocking_factor;
|
||||||
|
@ -267,7 +266,7 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
|
||||||
blk_mq_end_request(req, error);
|
blk_mq_end_request(req, error);
|
||||||
spin_unlock(&priv->lock);
|
spin_unlock(&priv->lock);
|
||||||
|
|
||||||
blk_mq_run_hw_queues(priv->queue, true);
|
blk_mq_run_hw_queues(priv->gendisk->queue, true);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,17 +440,20 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)
|
||||||
|
|
||||||
ps3disk_identify(dev);
|
ps3disk_identify(dev);
|
||||||
|
|
||||||
queue = blk_mq_init_sq_queue(&priv->tag_set, &ps3disk_mq_ops, 1,
|
error = blk_mq_alloc_sq_tag_set(&priv->tag_set, &ps3disk_mq_ops, 1,
|
||||||
BLK_MQ_F_SHOULD_MERGE);
|
BLK_MQ_F_SHOULD_MERGE);
|
||||||
if (IS_ERR(queue)) {
|
if (error)
|
||||||
dev_err(&dev->sbd.core, "%s:%u: blk_mq_init_queue failed\n",
|
|
||||||
__func__, __LINE__);
|
|
||||||
error = PTR_ERR(queue);
|
|
||||||
goto fail_teardown;
|
goto fail_teardown;
|
||||||
|
|
||||||
|
gendisk = blk_mq_alloc_disk(&priv->tag_set, dev);
|
||||||
|
if (IS_ERR(gendisk)) {
|
||||||
|
dev_err(&dev->sbd.core, "%s:%u: blk_mq_alloc_disk failed\n",
|
||||||
|
__func__, __LINE__);
|
||||||
|
error = PTR_ERR(gendisk);
|
||||||
|
goto fail_free_tag_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->queue = queue;
|
queue = gendisk->queue;
|
||||||
queue->queuedata = dev;
|
|
||||||
|
|
||||||
blk_queue_max_hw_sectors(queue, dev->bounce_size >> 9);
|
blk_queue_max_hw_sectors(queue, dev->bounce_size >> 9);
|
||||||
blk_queue_dma_alignment(queue, dev->blk_size-1);
|
blk_queue_dma_alignment(queue, dev->blk_size-1);
|
||||||
|
@ -462,19 +464,11 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)
|
||||||
blk_queue_max_segments(queue, -1);
|
blk_queue_max_segments(queue, -1);
|
||||||
blk_queue_max_segment_size(queue, dev->bounce_size);
|
blk_queue_max_segment_size(queue, dev->bounce_size);
|
||||||
|
|
||||||
gendisk = alloc_disk(PS3DISK_MINORS);
|
|
||||||
if (!gendisk) {
|
|
||||||
dev_err(&dev->sbd.core, "%s:%u: alloc_disk failed\n", __func__,
|
|
||||||
__LINE__);
|
|
||||||
error = -ENOMEM;
|
|
||||||
goto fail_cleanup_queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->gendisk = gendisk;
|
priv->gendisk = gendisk;
|
||||||
gendisk->major = ps3disk_major;
|
gendisk->major = ps3disk_major;
|
||||||
gendisk->first_minor = devidx * PS3DISK_MINORS;
|
gendisk->first_minor = devidx * PS3DISK_MINORS;
|
||||||
|
gendisk->minors = PS3DISK_MINORS;
|
||||||
gendisk->fops = &ps3disk_fops;
|
gendisk->fops = &ps3disk_fops;
|
||||||
gendisk->queue = queue;
|
|
||||||
gendisk->private_data = dev;
|
gendisk->private_data = dev;
|
||||||
snprintf(gendisk->disk_name, sizeof(gendisk->disk_name), PS3DISK_NAME,
|
snprintf(gendisk->disk_name, sizeof(gendisk->disk_name), PS3DISK_NAME,
|
||||||
devidx+'a');
|
devidx+'a');
|
||||||
|
@ -490,8 +484,7 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)
|
||||||
device_add_disk(&dev->sbd.core, gendisk, NULL);
|
device_add_disk(&dev->sbd.core, gendisk, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail_cleanup_queue:
|
fail_free_tag_set:
|
||||||
blk_cleanup_queue(queue);
|
|
||||||
blk_mq_free_tag_set(&priv->tag_set);
|
blk_mq_free_tag_set(&priv->tag_set);
|
||||||
fail_teardown:
|
fail_teardown:
|
||||||
ps3stor_teardown(dev);
|
ps3stor_teardown(dev);
|
||||||
|
@ -517,9 +510,8 @@ static void ps3disk_remove(struct ps3_system_bus_device *_dev)
|
||||||
&ps3disk_mask);
|
&ps3disk_mask);
|
||||||
mutex_unlock(&ps3disk_mask_mutex);
|
mutex_unlock(&ps3disk_mask_mutex);
|
||||||
del_gendisk(priv->gendisk);
|
del_gendisk(priv->gendisk);
|
||||||
blk_cleanup_queue(priv->queue);
|
blk_cleanup_disk(priv->gendisk);
|
||||||
blk_mq_free_tag_set(&priv->tag_set);
|
blk_mq_free_tag_set(&priv->tag_set);
|
||||||
put_disk(priv->gendisk);
|
|
||||||
dev_notice(&dev->sbd.core, "Synchronizing disk cache\n");
|
dev_notice(&dev->sbd.core, "Synchronizing disk cache\n");
|
||||||
ps3disk_sync_cache(dev);
|
ps3disk_sync_cache(dev);
|
||||||
ps3stor_teardown(dev);
|
ps3stor_teardown(dev);
|
||||||
|
|
Loading…
Add table
Reference in a new issue