From e32bc729a3a486e20443db3379ecf67240b20616 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 17 Mar 2016 18:23:09 -0700 Subject: 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 Reviewed-by: Johannes Thumshirn Signed-off-by: Dan Williams --- drivers/nvdimm/btt_devs.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'drivers/nvdimm/btt_devs.c') diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c index cb477518dd0e..1886171af80e 100644 --- a/drivers/nvdimm/btt_devs.c +++ b/drivers/nvdimm/btt_devs.c @@ -273,10 +273,11 @@ static int __nd_btt_probe(struct nd_btt *nd_btt, return 0; } -int nd_btt_probe(struct nd_namespace_common *ndns, void *drvdata) +int nd_btt_probe(struct device *dev, struct nd_namespace_common *ndns, + void *drvdata) { int rc; - struct device *dev; + struct device *btt_dev; struct btt_sb *btt_sb; struct nd_region *nd_region = to_nd_region(ndns->dev.parent); @@ -284,21 +285,20 @@ int nd_btt_probe(struct nd_namespace_common *ndns, void *drvdata) return -ENODEV; nvdimm_bus_lock(&ndns->dev); - dev = __nd_btt_create(nd_region, 0, NULL, ndns); + btt_dev = __nd_btt_create(nd_region, 0, NULL, ndns); nvdimm_bus_unlock(&ndns->dev); - if (!dev) + if (!btt_dev) return -ENOMEM; - dev_set_drvdata(dev, drvdata); - btt_sb = kzalloc(sizeof(*btt_sb), GFP_KERNEL); - rc = __nd_btt_probe(to_nd_btt(dev), ndns, btt_sb); - kfree(btt_sb); - dev_dbg(&ndns->dev, "%s: btt: %s\n", __func__, - rc == 0 ? dev_name(dev) : ""); + dev_set_drvdata(btt_dev, drvdata); + btt_sb = devm_kzalloc(dev, sizeof(*btt_sb), GFP_KERNEL); + rc = __nd_btt_probe(to_nd_btt(btt_dev), ndns, btt_sb); + dev_dbg(dev, "%s: btt: %s\n", __func__, + rc == 0 ? dev_name(btt_dev) : ""); if (rc < 0) { - struct nd_btt *nd_btt = to_nd_btt(dev); + struct nd_btt *nd_btt = to_nd_btt(btt_dev); - __nd_detach_ndns(dev, &nd_btt->ndns); - put_device(dev); + __nd_detach_ndns(btt_dev, &nd_btt->ndns); + put_device(btt_dev); } return rc; -- cgit