Commit 8f91fb68 authored by Jingoo Han's avatar Jingoo Han Committed by Brian Norris

mtd: tmio_nand: Use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent e8009ca0
...@@ -371,11 +371,9 @@ static int tmio_probe(struct platform_device *dev) ...@@ -371,11 +371,9 @@ static int tmio_probe(struct platform_device *dev)
if (data == NULL) if (data == NULL)
dev_warn(&dev->dev, "NULL platform data!\n"); dev_warn(&dev->dev, "NULL platform data!\n");
tmio = kzalloc(sizeof *tmio, GFP_KERNEL); tmio = devm_kzalloc(&dev->dev, sizeof(*tmio), GFP_KERNEL);
if (!tmio) { if (!tmio)
retval = -ENOMEM; return -ENOMEM;
goto err_kzalloc;
}
tmio->dev = dev; tmio->dev = dev;
...@@ -385,22 +383,18 @@ static int tmio_probe(struct platform_device *dev) ...@@ -385,22 +383,18 @@ static int tmio_probe(struct platform_device *dev)
mtd->priv = nand_chip; mtd->priv = nand_chip;
mtd->name = "tmio-nand"; mtd->name = "tmio-nand";
tmio->ccr = ioremap(ccr->start, resource_size(ccr)); tmio->ccr = devm_ioremap(&dev->dev, ccr->start, resource_size(ccr));
if (!tmio->ccr) { if (!tmio->ccr)
retval = -EIO; return -EIO;
goto err_iomap_ccr;
}
tmio->fcr_base = fcr->start & 0xfffff; tmio->fcr_base = fcr->start & 0xfffff;
tmio->fcr = ioremap(fcr->start, resource_size(fcr)); tmio->fcr = devm_ioremap(&dev->dev, fcr->start, resource_size(fcr));
if (!tmio->fcr) { if (!tmio->fcr)
retval = -EIO; return -EIO;
goto err_iomap_fcr;
}
retval = tmio_hw_init(dev, tmio); retval = tmio_hw_init(dev, tmio);
if (retval) if (retval)
goto err_hwinit; return retval;
/* Set address of NAND IO lines */ /* Set address of NAND IO lines */
nand_chip->IO_ADDR_R = tmio->fcr; nand_chip->IO_ADDR_R = tmio->fcr;
...@@ -428,7 +422,8 @@ static int tmio_probe(struct platform_device *dev) ...@@ -428,7 +422,8 @@ static int tmio_probe(struct platform_device *dev)
/* 15 us command delay time */ /* 15 us command delay time */
nand_chip->chip_delay = 15; nand_chip->chip_delay = 15;
retval = request_irq(irq, &tmio_irq, 0, dev_name(&dev->dev), tmio); retval = devm_request_irq(&dev->dev, irq, &tmio_irq, 0,
dev_name(&dev->dev), tmio);
if (retval) { if (retval) {
dev_err(&dev->dev, "request_irq error %d\n", retval); dev_err(&dev->dev, "request_irq error %d\n", retval);
goto err_irq; goto err_irq;
...@@ -440,7 +435,7 @@ static int tmio_probe(struct platform_device *dev) ...@@ -440,7 +435,7 @@ static int tmio_probe(struct platform_device *dev)
/* Scan to find existence of the device */ /* Scan to find existence of the device */
if (nand_scan(mtd, 1)) { if (nand_scan(mtd, 1)) {
retval = -ENODEV; retval = -ENODEV;
goto err_scan; goto err_irq;
} }
/* Register the partitions */ /* Register the partitions */
retval = mtd_device_parse_register(mtd, NULL, NULL, retval = mtd_device_parse_register(mtd, NULL, NULL,
...@@ -451,18 +446,8 @@ static int tmio_probe(struct platform_device *dev) ...@@ -451,18 +446,8 @@ static int tmio_probe(struct platform_device *dev)
nand_release(mtd); nand_release(mtd);
err_scan:
if (tmio->irq)
free_irq(tmio->irq, tmio);
err_irq: err_irq:
tmio_hw_stop(dev, tmio); tmio_hw_stop(dev, tmio);
err_hwinit:
iounmap(tmio->fcr);
err_iomap_fcr:
iounmap(tmio->ccr);
err_iomap_ccr:
kfree(tmio);
err_kzalloc:
return retval; return retval;
} }
...@@ -471,12 +456,7 @@ static int tmio_remove(struct platform_device *dev) ...@@ -471,12 +456,7 @@ static int tmio_remove(struct platform_device *dev)
struct tmio_nand *tmio = platform_get_drvdata(dev); struct tmio_nand *tmio = platform_get_drvdata(dev);
nand_release(&tmio->mtd); nand_release(&tmio->mtd);
if (tmio->irq)
free_irq(tmio->irq, tmio);
tmio_hw_stop(dev, tmio); tmio_hw_stop(dev, tmio);
iounmap(tmio->fcr);
iounmap(tmio->ccr);
kfree(tmio);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment