diff options
author | Dan Williams <dan.j.williams@intel.com> | 2016-03-17 21:23:09 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2016-04-22 13:59:54 -0400 |
commit | e32bc729a3a486e20443db3379ecf67240b20616 (patch) | |
tree | 1d4e0b6dd686eb88766581cce79b59ab04266284 /drivers/nvdimm/btt.c | |
parent | bd032943b5b2b336994171dcebc11531a38b45ba (diff) |
libnvdimm, btt, convert nd_btt_probe() to devm
Pass the device performing the probe so we can use a devm allocation for
the btt superblock.
Cc: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/nvdimm/btt.c')
-rw-r--r-- | drivers/nvdimm/btt.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 676c31a8fb6d..cc9fafed9362 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c | |||
@@ -1306,7 +1306,7 @@ static struct btt *btt_init(struct nd_btt *nd_btt, unsigned long long rawsize, | |||
1306 | struct btt *btt; | 1306 | struct btt *btt; |
1307 | struct device *dev = &nd_btt->dev; | 1307 | struct device *dev = &nd_btt->dev; |
1308 | 1308 | ||
1309 | btt = kzalloc(sizeof(struct btt), GFP_KERNEL); | 1309 | btt = devm_kzalloc(dev, sizeof(struct btt), GFP_KERNEL); |
1310 | if (!btt) | 1310 | if (!btt) |
1311 | return NULL; | 1311 | return NULL; |
1312 | 1312 | ||
@@ -1321,13 +1321,13 @@ static struct btt *btt_init(struct nd_btt *nd_btt, unsigned long long rawsize, | |||
1321 | ret = discover_arenas(btt); | 1321 | ret = discover_arenas(btt); |
1322 | if (ret) { | 1322 | if (ret) { |
1323 | dev_err(dev, "init: error in arena_discover: %d\n", ret); | 1323 | dev_err(dev, "init: error in arena_discover: %d\n", ret); |
1324 | goto out_free; | 1324 | return NULL; |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | if (btt->init_state != INIT_READY && nd_region->ro) { | 1327 | if (btt->init_state != INIT_READY && nd_region->ro) { |
1328 | dev_info(dev, "%s is read-only, unable to init btt metadata\n", | 1328 | dev_info(dev, "%s is read-only, unable to init btt metadata\n", |
1329 | dev_name(&nd_region->dev)); | 1329 | dev_name(&nd_region->dev)); |
1330 | goto out_free; | 1330 | return NULL; |
1331 | } else if (btt->init_state != INIT_READY) { | 1331 | } else if (btt->init_state != INIT_READY) { |
1332 | btt->num_arenas = (rawsize / ARENA_MAX_SIZE) + | 1332 | btt->num_arenas = (rawsize / ARENA_MAX_SIZE) + |
1333 | ((rawsize % ARENA_MAX_SIZE) ? 1 : 0); | 1333 | ((rawsize % ARENA_MAX_SIZE) ? 1 : 0); |
@@ -1337,29 +1337,25 @@ static struct btt *btt_init(struct nd_btt *nd_btt, unsigned long long rawsize, | |||
1337 | ret = create_arenas(btt); | 1337 | ret = create_arenas(btt); |
1338 | if (ret) { | 1338 | if (ret) { |
1339 | dev_info(dev, "init: create_arenas: %d\n", ret); | 1339 | dev_info(dev, "init: create_arenas: %d\n", ret); |
1340 | goto out_free; | 1340 | return NULL; |
1341 | } | 1341 | } |
1342 | 1342 | ||
1343 | ret = btt_meta_init(btt); | 1343 | ret = btt_meta_init(btt); |
1344 | if (ret) { | 1344 | if (ret) { |
1345 | dev_err(dev, "init: error in meta_init: %d\n", ret); | 1345 | dev_err(dev, "init: error in meta_init: %d\n", ret); |
1346 | goto out_free; | 1346 | return NULL; |
1347 | } | 1347 | } |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | ret = btt_blk_init(btt); | 1350 | ret = btt_blk_init(btt); |
1351 | if (ret) { | 1351 | if (ret) { |
1352 | dev_err(dev, "init: error in blk_init: %d\n", ret); | 1352 | dev_err(dev, "init: error in blk_init: %d\n", ret); |
1353 | goto out_free; | 1353 | return NULL; |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | btt_debugfs_init(btt); | 1356 | btt_debugfs_init(btt); |
1357 | 1357 | ||
1358 | return btt; | 1358 | return btt; |
1359 | |||
1360 | out_free: | ||
1361 | kfree(btt); | ||
1362 | return NULL; | ||
1363 | } | 1359 | } |
1364 | 1360 | ||
1365 | /** | 1361 | /** |
@@ -1377,7 +1373,6 @@ static void btt_fini(struct btt *btt) | |||
1377 | btt_blk_cleanup(btt); | 1373 | btt_blk_cleanup(btt); |
1378 | free_arenas(btt); | 1374 | free_arenas(btt); |
1379 | debugfs_remove_recursive(btt->debugfs_dir); | 1375 | debugfs_remove_recursive(btt->debugfs_dir); |
1380 | kfree(btt); | ||
1381 | } | 1376 | } |
1382 | } | 1377 | } |
1383 | 1378 | ||