[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210927220039.1064193-6-mcgrof@kernel.org>
Date: Mon, 27 Sep 2021 15:00:34 -0700
From: Luis Chamberlain <mcgrof@...nel.org>
To: axboe@...nel.dk, colyli@...e.de, kent.overstreet@...il.com,
kbusch@...nel.org, sagi@...mberg.me, vishal.l.verma@...el.com,
dan.j.williams@...el.com, dave.jiang@...el.com,
ira.weiny@...el.com, konrad.wilk@...cle.com, roger.pau@...rix.com,
boris.ostrovsky@...cle.com, jgross@...e.com,
sstabellini@...nel.org, minchan@...nel.org, ngupta@...are.org,
senozhatsky@...omium.org
Cc: xen-devel@...ts.xenproject.org, nvdimm@...ts.linux.dev,
linux-nvme@...ts.infradead.org, linux-bcache@...r.kernel.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
Luis Chamberlain <mcgrof@...nel.org>
Subject: [PATCH v2 05/10] nvdimm/btt: use goto error labels on btt_blk_init()
This will make it easier to share common error paths.
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
drivers/nvdimm/btt.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 29cc7325e890..23ee8c005db5 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1520,10 +1520,11 @@ static int btt_blk_init(struct btt *btt)
{
struct nd_btt *nd_btt = btt->nd_btt;
struct nd_namespace_common *ndns = nd_btt->ndns;
+ int rc = -ENOMEM;
btt->btt_disk = blk_alloc_disk(NUMA_NO_NODE);
if (!btt->btt_disk)
- return -ENOMEM;
+ goto out;
nvdimm_namespace_disk_name(ndns, btt->btt_disk->disk_name);
btt->btt_disk->first_minor = 0;
@@ -1535,19 +1536,23 @@ static int btt_blk_init(struct btt *btt)
blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_disk->queue);
if (btt_meta_size(btt)) {
- int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
-
- if (rc) {
- blk_cleanup_disk(btt->btt_disk);
- return rc;
- }
+ rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt));
+ if (rc)
+ goto out_cleanup_disk;
}
+
set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL);
+
btt->nd_btt->size = btt->nlba * (u64)btt->sector_size;
nvdimm_check_and_set_ro(btt->btt_disk);
return 0;
+
+out_cleanup_disk:
+ blk_cleanup_disk(btt->btt_disk);
+out:
+ return rc;
}
static void btt_blk_cleanup(struct btt *btt)
--
2.30.2
Powered by blists - more mailing lists