[RFC PATCH 18/18] ubi: use init disk helper

From: Chaitanya Kulkarni
Date: Wed Oct 05 2022 - 01:06:45 EST


Add and use the helper to initialize the common fields of struct gendisk
such as major, first_minor, minors, disk_name, private_data, and ops.
This initialization is spread all over the block drivers. This avoids
code repetation of inialization code of gendisk in current block drivers
and any future ones.

Signed-off-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>
---
drivers/mtd/ubi/block.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 4cf67a2a0d04..07c085a5fd52 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -420,9 +420,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
goto out_free_tags;
}

- gd->fops = &ubiblock_ops;
- gd->major = ubiblock_major;
- gd->minors = 1;
+ init_disk(gd, ubiblock_major, 1, 0, disk_capacity, dev, &ubiblock_ops);
gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL);
if (gd->first_minor < 0) {
dev_err(disk_to_dev(gd),
@@ -431,9 +429,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
goto out_cleanup_disk;
}
gd->flags |= GENHD_FL_NO_PART;
- gd->private_data = dev;
sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
- set_capacity(gd, disk_capacity);
dev->gd = gd;

dev->rq = gd->queue;
--
2.29.0