Skip to content

Commit

Permalink
z2ram: use blk_mq_alloc_disk and blk_cleanup_disk
Browse files Browse the repository at this point in the history
Use blk_mq_alloc_disk and blk_cleanup_disk 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-31-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Jun 11, 2021
1 parent fd71c8a commit ec06c98
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions drivers/block/z2ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,27 +323,20 @@ static const struct blk_mq_ops z2_mq_ops = {

static int z2ram_register_disk(int minor)
{
struct request_queue *q;
struct gendisk *disk;

disk = alloc_disk(1);
if (!disk)
return -ENOMEM;

q = blk_mq_init_queue(&tag_set);
if (IS_ERR(q)) {
put_disk(disk);
return PTR_ERR(q);
}
disk = blk_mq_alloc_disk(&tag_set, NULL);
if (IS_ERR(disk))
return PTR_ERR(disk);

disk->major = Z2RAM_MAJOR;
disk->first_minor = minor;
disk->minors = 1;
disk->fops = &z2_fops;
if (minor)
sprintf(disk->disk_name, "z2ram%d", minor);
else
sprintf(disk->disk_name, "z2ram");
disk->queue = q;

z2ram_gendisk[minor] = disk;
add_disk(disk);
Expand Down

0 comments on commit ec06c98

Please sign in to comment.