[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221005050027.39591-15-kch@nvidia.com>
Date: Tue, 4 Oct 2022 22:00:23 -0700
From: Chaitanya Kulkarni <kch@...dia.com>
To: <ogeert@...ux-m68k.org>, <linux-block@...r.kernel.org>,
<linux-m68k@...ts.linux-m68k.org>, <linux-kernel@...r.kernel.org>,
<drbd-dev@...ts.linbit.com>, <nbd@...er.debian.org>,
<linux-mtd@...ts.infradead.org>
CC: <axboe@...nel.dk>, <philipp.reisner@...bit.com>,
<lars.ellenberg@...bit.com>, <christoph.boehmwalder@...bit.com>,
<efremov@...ux.com>, <josef@...icpanda.com>, <tim@...erelk.net>,
<haris.iqbal@...os.com>, <jinpu.wang@...os.com>, <richard@....at>,
<miquel.raynal@...tlin.com>, <vigneshr@...com>, <kch@...dia.com>,
<mcgrof@...nel.org>, <hare@...e.de>,
<damien.lemoal@...nsource.wdc.com>, <johannes.thumshirn@....com>,
<bvanassche@....org>, <ming.lei@...hat.com>,
<vincent.fu@...sung.com>, <shinichiro.kawasaki@....com>
Subject: [RFC PATCH 14/18] rnbd-clt: use init disk helper
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@...dia.com>
---
drivers/block/rnbd/rnbd-clt.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 78334da74d8b..4f29364a6f4d 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -1369,12 +1369,7 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev,
{
int err;
- dev->gd->major = rnbd_client_major;
- dev->gd->first_minor = idx << RNBD_PART_BITS;
- dev->gd->minors = 1 << RNBD_PART_BITS;
- dev->gd->fops = &rnbd_client_ops;
dev->gd->queue = dev->queue;
- dev->gd->private_data = dev;
snprintf(dev->gd->disk_name, sizeof(dev->gd->disk_name), "rnbd%d",
idx);
pr_debug("disk_name=%s, capacity=%llu\n",
@@ -1382,7 +1377,9 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev,
le64_to_cpu(rsp->nsectors) *
(le16_to_cpu(rsp->logical_block_size) / SECTOR_SIZE));
- set_capacity(dev->gd, le64_to_cpu(rsp->nsectors));
+ init_disk(dev->gd, rnbd_client_major, idx << RNBD_PART_BITS,
+ 1 << RNBD_PART_BITS, le64_to_cpu(rsp->nsectors), dev,
+ &rnbd_client_ops);
if (dev->access_mode == RNBD_ACCESS_RO)
set_disk_ro(dev->gd, true);
--
2.29.0
Powered by blists - more mailing lists