[RFC PATCH 11/18] pd: use init disk helper

From: Chaitanya Kulkarni
Date: Wed Oct 05 2022 - 01:04:31 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/paride/pd.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index f8a75bc90f70..9457ad0cc25f 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -919,12 +919,7 @@ static int pd_probe_drive(struct pd_unit *disk, int autoprobe, int port,
disk->gd = p;

strcpy(p->disk_name, disk->name);
- p->fops = &pd_fops;
- p->major = major;
- p->first_minor = (disk - pd) << PD_BITS;
- p->minors = 1 << PD_BITS;
p->events = DISK_EVENT_MEDIA_CHANGE;
- p->private_data = disk;
blk_queue_max_hw_sectors(p->queue, cluster);
blk_queue_bounce_limit(p->queue, BLK_BOUNCE_HIGH);

@@ -939,7 +934,8 @@ static int pd_probe_drive(struct pd_unit *disk, int autoprobe, int port,
}
if (ret)
goto put_disk;
- set_capacity(disk->gd, disk->capacity);
+ init_disk(disk, major, (disk - pd) << PD_BITS, 1 << PD_BITS,
+ disk->capacity, disk, *pd_fops);
ret = add_disk(disk->gd);
if (ret)
goto cleanup_disk;
--
2.29.0