[PATCH 1/2] mtd: fsl_ifc_nand: Use devm_* throughout driver
Aaron Sierra
asierra at xes-inc.com
Fri Aug 15 17:46:44 PDT 2014
For consistency, use managed resources for allocations and remaps
throughout the driver.
Signed-off-by: Aaron Sierra <asierra at 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
More information about the linux-mtd
mailing list