Message ID | 20221005050027.39591-16-kch@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: add and use init disk helper | expand |
On Tue, 4 Oct 2022, Chaitanya Kulkarni wrote: > 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@nvidia.com> > --- > drivers/block/swim.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/block/swim.c b/drivers/block/swim.c > index 42b4b6828690..7fa4b2766367 100644 > --- a/drivers/block/swim.c > +++ b/drivers/block/swim.c > @@ -835,15 +835,12 @@ static int swim_floppy_init(struct swim_priv *swd) > > for (drive = 0; drive < swd->floppy_count; drive++) { > swd->unit[drive].disk->flags = GENHD_FL_REMOVABLE; > - swd->unit[drive].disk->major = FLOPPY_MAJOR; > - swd->unit[drive].disk->first_minor = drive; > - swd->unit[drive].disk->minors = 1; > sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); > - swd->unit[drive].disk->fops = &floppy_fops; > swd->unit[drive].disk->flags |= GENHD_FL_NO_PART; > swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE; > swd->unit[drive].disk->private_data = &swd->unit[drive]; > - set_capacity(swd->unit[drive].disk, 2880); > + init_disk(swd->unit[drive].disk, FLOPPY_MAJOR, drive, 1, 2880, > + &swd->unit[drive], &floopy_dops); > err = add_disk(swd->unit[drive].disk); > if (err) > goto exit_put_disks; > You typo'd the ops struct. By inspection, I'd say your patches 11/18 and 16/18 will not compile either.
diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 42b4b6828690..7fa4b2766367 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -835,15 +835,12 @@ static int swim_floppy_init(struct swim_priv *swd) for (drive = 0; drive < swd->floppy_count; drive++) { swd->unit[drive].disk->flags = GENHD_FL_REMOVABLE; - swd->unit[drive].disk->major = FLOPPY_MAJOR; - swd->unit[drive].disk->first_minor = drive; - swd->unit[drive].disk->minors = 1; sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive); - swd->unit[drive].disk->fops = &floppy_fops; swd->unit[drive].disk->flags |= GENHD_FL_NO_PART; swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE; swd->unit[drive].disk->private_data = &swd->unit[drive]; - set_capacity(swd->unit[drive].disk, 2880); + init_disk(swd->unit[drive].disk, FLOPPY_MAJOR, drive, 1, 2880, + &swd->unit[drive], &floopy_dops); err = add_disk(swd->unit[drive].disk); if (err) goto exit_put_disks;
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@nvidia.com> --- drivers/block/swim.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)