From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 09A91420671 for ; Wed, 5 Oct 2022 07:17:36 +0200 (CEST) From: Chaitanya Kulkarni To: , , , , , , Date: Tue, 4 Oct 2022 22:00:18 -0700 Message-ID: <20221005050027.39591-10-kch@nvidia.com> In-Reply-To: <20221005050027.39591-1-kch@nvidia.com> References: <20221005050027.39591-1-kch@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Cc: axboe@kernel.dk, vincent.fu@samsung.com, ming.lei@redhat.com, kch@nvidia.com, vigneshr@ti.com, richard@nod.at, damien.lemoal@opensource.wdc.com, philipp.reisner@linbit.com, efremov@linux.com, josef@toxicpanda.com, mcgrof@kernel.org, haris.iqbal@ionos.com, hare@suse.de, miquel.raynal@bootlin.com, shinichiro.kawasaki@wdc.com, lars.ellenberg@linbit.com, johannes.thumshirn@wdc.com, jinpu.wang@ionos.com, tim@cyberelk.net, bvanassche@acm.org Subject: [Drbd-dev] [RFC PATCH 09/18] nbd: use init disk helper List-Id: "*Coordination* of development, patches, contributions -- *Questions* \(even to developers\) go to drbd-user, please." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 --- 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