diff options
author | Dan Williams <dan.j.williams@intel.com> | 2016-07-19 17:51:40 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2016-10-07 16:45:59 -0700 |
commit | d76911ee933a64c9dfc453e580e7ad612b394e83 (patch) | |
tree | dad6ced4a5968e946e2bec11b9e76b4518f199d9 /drivers/dax/dax.c | |
parent | 9d2d01a031a945075d4609b1c4d3c73f10ba61e7 (diff) |
dax: convert devm_create_dax_dev to PTR_ERR
For sub-division support we need access to the dax_dev created by
devm_create_dax_dev().
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dax/dax.c')
-rw-r--r-- | drivers/dax/dax.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c index 03bb54f7f58f..e7d8a3902437 100644 --- a/drivers/dax/dax.c +++ b/drivers/dax/dax.c @@ -558,8 +558,8 @@ static void unregister_dax_dev(void *dev) device_unregister(dev); } -int devm_create_dax_dev(struct dax_region *dax_region, struct resource *res, - int count) +struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region, + struct resource *res, int count) { struct device *parent = dax_region->dev; struct dax_dev *dax_dev; @@ -570,7 +570,7 @@ int devm_create_dax_dev(struct dax_region *dax_region, struct resource *res, dax_dev = kzalloc(sizeof(*dax_dev) + sizeof(*res) * count, GFP_KERNEL); if (!dax_dev) - return -ENOMEM; + return ERR_PTR(-ENOMEM); for (i = 0; i < count; i++) { if (!IS_ALIGNED(res[i].start, dax_region->align) @@ -632,10 +632,14 @@ int devm_create_dax_dev(struct dax_region *dax_region, struct resource *res, rc = device_add(dev); if (rc) { put_device(dev); - return rc; + return ERR_PTR(rc); } - return devm_add_action_or_reset(dax_region->dev, unregister_dax_dev, dev); + rc = devm_add_action_or_reset(dax_region->dev, unregister_dax_dev, dev); + if (rc) + return ERR_PTR(rc); + + return dax_dev; err_cdev: iput(dax_dev->inode); @@ -646,7 +650,7 @@ int devm_create_dax_dev(struct dax_region *dax_region, struct resource *res, err_id: kfree(dax_dev); - return rc; + return ERR_PTR(rc); } EXPORT_SYMBOL_GPL(devm_create_dax_dev); |