public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: fsl_ifc_nand: Use devm_* throughout driver
@ 2014-08-16  0:46 Aaron Sierra
  2014-08-16  0:47 ` [PATCH 2/2] mtd: fsl_ifc_nand: Probe partitions OF node Aaron Sierra
  2014-09-28  0:19 ` [PATCH 1/2] mtd: fsl_ifc_nand: Use devm_* throughout driver Brian Norris
  0 siblings, 2 replies; 8+ messages in thread
From: Aaron Sierra @ 2014-08-16  0:46 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris; +Cc: linux-mtd, Prabhakar Kushwaha

For consistency, use managed resources for allocations and remaps
throughout the driver.

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
---
 drivers/mtd/nand/fsl_ifc_nand.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index 2338124..7861909 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -997,9 +997,6 @@ static int fsl_ifc_chip_remove(struct fsl_ifc_mtd *priv)
 
 	kfree(priv->mtd.name);
 
-	if (priv->vbase)
-		iounmap(priv->vbase);
-
 	ifc_nand_ctrl->chips[priv->bank] = NULL;
 
 	return 0;
@@ -1062,7 +1059,8 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
 
 	mutex_lock(&fsl_ifc_nand_mutex);
 	if (!fsl_ifc_ctrl_dev->nand) {
-		ifc_nand_ctrl = kzalloc(sizeof(*ifc_nand_ctrl), GFP_KERNEL);
+		ifc_nand_ctrl = devm_kzalloc(&dev->dev,
+					sizeof(*ifc_nand_ctrl), GFP_KERNEL);
 		if (!ifc_nand_ctrl) {
 			mutex_unlock(&fsl_ifc_nand_mutex);
 			return -ENOMEM;
@@ -1085,7 +1083,7 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
 	priv->ctrl = fsl_ifc_ctrl_dev;
 	priv->dev = &dev->dev;
 
-	priv->vbase = ioremap(res.start, resource_size(&res));
+	priv->vbase = devm_ioremap(priv->dev, res.start, resource_size(&res));
 	if (!priv->vbase) {
 		dev_err(priv->dev, "%s: failed to map chip region\n", __func__);
 		ret = -ENOMEM;
@@ -1148,10 +1146,8 @@ static int fsl_ifc_nand_remove(struct platform_device *dev)
 
 	mutex_lock(&fsl_ifc_nand_mutex);
 	ifc_nand_ctrl->counter--;
-	if (!ifc_nand_ctrl->counter) {
+	if (!ifc_nand_ctrl->counter)
 		fsl_ifc_ctrl_dev->nand = NULL;
-		kfree(ifc_nand_ctrl);
-	}
 	mutex_unlock(&fsl_ifc_nand_mutex);
 
 	return 0;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-09-28  0:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-16  0:46 [PATCH 1/2] mtd: fsl_ifc_nand: Use devm_* throughout driver Aaron Sierra
2014-08-16  0:47 ` [PATCH 2/2] mtd: fsl_ifc_nand: Probe partitions OF node Aaron Sierra
2014-08-20 23:26   ` Scott Wood
2014-08-20 23:45     ` Aaron Sierra
2014-08-20 23:59       ` Scott Wood
2014-08-21  0:15         ` Aaron Sierra
2014-08-21  0:17           ` Scott Wood
2014-09-28  0:19 ` [PATCH 1/2] mtd: fsl_ifc_nand: Use devm_* throughout driver Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox