[RFC PATCH 17/18] z2ram: use init disk helper
From: Chaitanya Kulkarni
Date: Wed Oct 05 2022 - 01:06:56 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/block/z2ram.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index c1e85f356e4d..74432fbfe42c 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -324,11 +324,8 @@ static int z2ram_register_disk(int minor)
if (IS_ERR(disk))
return PTR_ERR(disk);
- disk->major = Z2RAM_MAJOR;
- disk->first_minor = minor;
- disk->minors = 1;
disk->flags |= GENHD_FL_NO_PART;
- disk->fops = &z2_fops;
+ init_disk(disk, Z2RAM_MAJOR, minor, 1, 0, NULL, &z2_fops);
if (minor)
sprintf(disk->disk_name, "z2ram%d", minor);
else
--
2.29.0