[RFC PATCH 17/18] z2ram: use init disk helper
Chaitanya Kulkarni
kch at nvidia.com
Tue Oct 4 22:00:26 PDT 2022
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 at nvidia.com>
---
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
More information about the linux-mtd
mailing list