lkml.org 
[lkml]   [2022]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 09/18] nbd: use init disk helper
Date
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/nbd.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 2a2a1d996a57..b4f2d7e1be89 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1816,12 +1816,9 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)
*/
refcount_set(&nbd->refs, 0);
INIT_LIST_HEAD(&nbd->list);
- disk->major = NBD_MAJOR;
- disk->first_minor = index << part_shift;
- disk->minors = 1 << part_shift;
- disk->fops = &nbd_fops;
- disk->private_data = nbd;
sprintf(disk->disk_name, "nbd%d", index);
+ init_disk(disk, NBD_MAJOR, index << part_shift, 1 << part_shift, 0,
+ nbd, &nbd_fops);
err = add_disk(disk);
if (err)
goto out_free_work;
--
2.29.0
\
 
 \ /
  Last update: 2022-10-05 07:04    [W:0.134 / U:1.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site