[RFC PATCH 07/18] loop: use init disk helper
Chaitanya Kulkarni
kch at nvidia.com
Tue Oct 4 22:00:16 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/loop.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ad92192c7d61..82cdb57ecd18 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2023,15 +2023,12 @@ static int loop_add(int i)
spin_lock_init(&lo->lo_work_lock);
INIT_WORK(&lo->rootcg_work, loop_rootcg_workfn);
INIT_LIST_HEAD(&lo->rootcg_cmd_list);
- disk->major = LOOP_MAJOR;
- disk->first_minor = i << part_shift;
- disk->minors = 1 << part_shift;
- disk->fops = &lo_fops;
- disk->private_data = lo;
disk->queue = lo->lo_queue;
disk->events = DISK_EVENT_MEDIA_CHANGE;
disk->event_flags = DISK_EVENT_FLAG_UEVENT;
sprintf(disk->disk_name, "loop%d", i);
+ init_disk(disk, LOOP_MAJOR, i << part_shift, 1 << part_shift, 0, lo,
+ &lo_fops);
/* Make this loop device reachable from pathname. */
err = add_disk(disk);
if (err)
--
2.29.0
More information about the linux-mtd
mailing list