Commit 0be7966e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

rsxx: convert to blk_alloc_disk/blk_cleanup_disk

Convert the rsxx driver to use the blk_alloc_disk and blk_cleanup_disk
helpers to simplify gendisk and request_queue allocation.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-10-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 44413484
...@@ -236,47 +236,40 @@ int rsxx_setup_dev(struct rsxx_cardinfo *card) ...@@ -236,47 +236,40 @@ int rsxx_setup_dev(struct rsxx_cardinfo *card)
return -ENOMEM; return -ENOMEM;
} }
card->queue = blk_alloc_queue(NUMA_NO_NODE); card->gendisk = blk_alloc_disk(blkdev_minors);
if (!card->queue) {
dev_err(CARD_TO_DEV(card), "Failed queue alloc\n");
unregister_blkdev(card->major, DRIVER_NAME);
return -ENOMEM;
}
card->gendisk = alloc_disk(blkdev_minors);
if (!card->gendisk) { if (!card->gendisk) {
dev_err(CARD_TO_DEV(card), "Failed disk alloc\n"); dev_err(CARD_TO_DEV(card), "Failed disk alloc\n");
blk_cleanup_queue(card->queue);
unregister_blkdev(card->major, DRIVER_NAME); unregister_blkdev(card->major, DRIVER_NAME);
return -ENOMEM; return -ENOMEM;
} }
if (card->config_valid) { if (card->config_valid) {
blk_size = card->config.data.block_size; blk_size = card->config.data.block_size;
blk_queue_dma_alignment(card->queue, blk_size - 1); blk_queue_dma_alignment(card->gendisk->queue, blk_size - 1);
blk_queue_logical_block_size(card->queue, blk_size); blk_queue_logical_block_size(card->gendisk->queue, blk_size);
} }
blk_queue_max_hw_sectors(card->queue, blkdev_max_hw_sectors); blk_queue_max_hw_sectors(card->gendisk->queue, blkdev_max_hw_sectors);
blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE); blk_queue_physical_block_size(card->gendisk->queue, RSXX_HW_BLK_SIZE);
blk_queue_flag_set(QUEUE_FLAG_NONROT, card->queue); blk_queue_flag_set(QUEUE_FLAG_NONROT, card->gendisk->queue);
blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, card->queue); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, card->gendisk->queue);
if (rsxx_discard_supported(card)) { if (rsxx_discard_supported(card)) {
blk_queue_flag_set(QUEUE_FLAG_DISCARD, card->queue); blk_queue_flag_set(QUEUE_FLAG_DISCARD, card->gendisk->queue);
blk_queue_max_discard_sectors(card->queue, blk_queue_max_discard_sectors(card->gendisk->queue,
RSXX_HW_BLK_SIZE >> 9); RSXX_HW_BLK_SIZE >> 9);
card->queue->limits.discard_granularity = RSXX_HW_BLK_SIZE; card->gendisk->queue->limits.discard_granularity =
card->queue->limits.discard_alignment = RSXX_HW_BLK_SIZE; RSXX_HW_BLK_SIZE;
card->gendisk->queue->limits.discard_alignment =
RSXX_HW_BLK_SIZE;
} }
snprintf(card->gendisk->disk_name, sizeof(card->gendisk->disk_name), snprintf(card->gendisk->disk_name, sizeof(card->gendisk->disk_name),
"rsxx%d", card->disk_id); "rsxx%d", card->disk_id);
card->gendisk->major = card->major; card->gendisk->major = card->major;
card->gendisk->first_minor = 0; card->gendisk->minors = blkdev_minors;
card->gendisk->fops = &rsxx_fops; card->gendisk->fops = &rsxx_fops;
card->gendisk->private_data = card; card->gendisk->private_data = card;
card->gendisk->queue = card->queue;
return 0; return 0;
} }
...@@ -286,10 +279,8 @@ void rsxx_destroy_dev(struct rsxx_cardinfo *card) ...@@ -286,10 +279,8 @@ void rsxx_destroy_dev(struct rsxx_cardinfo *card)
if (!enable_blkdev) if (!enable_blkdev)
return; return;
put_disk(card->gendisk); blk_cleanup_disk(card->gendisk);
card->gendisk = NULL; card->gendisk = NULL;
blk_cleanup_queue(card->queue);
unregister_blkdev(card->major, DRIVER_NAME); unregister_blkdev(card->major, DRIVER_NAME);
} }
......
...@@ -154,7 +154,6 @@ struct rsxx_cardinfo { ...@@ -154,7 +154,6 @@ struct rsxx_cardinfo {
bool bdev_attached; bool bdev_attached;
int disk_id; int disk_id;
int major; int major;
struct request_queue *queue;
struct gendisk *gendisk; struct gendisk *gendisk;
struct { struct {
/* Used to convert a byte address to a device address. */ /* Used to convert a byte address to a device address. */
......
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