mtd: socrates_nand: Use devm_kzalloc

devm_kzalloc is device managed and makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:
Sachin Kamat 2013-10-08 15:31:46 +05:30 committed by Brian Norris
parent ecb598d0b2
commit cf3a9b56a1
1 changed files with 2 additions and 8 deletions

View File

@ -149,17 +149,13 @@ static int socrates_nand_probe(struct platform_device *ofdev)
struct mtd_part_parser_data ppdata; struct mtd_part_parser_data ppdata;
/* Allocate memory for the device structure (and zero it) */ /* Allocate memory for the device structure (and zero it) */
host = kzalloc(sizeof(struct socrates_nand_host), GFP_KERNEL); host = devm_kzalloc(&ofdev->dev, sizeof(*host), GFP_KERNEL);
if (!host) { if (!host)
printk(KERN_ERR
"socrates_nand: failed to allocate device structure.\n");
return -ENOMEM; return -ENOMEM;
}
host->io_base = of_iomap(ofdev->dev.of_node, 0); host->io_base = of_iomap(ofdev->dev.of_node, 0);
if (host->io_base == NULL) { if (host->io_base == NULL) {
printk(KERN_ERR "socrates_nand: ioremap failed\n"); printk(KERN_ERR "socrates_nand: ioremap failed\n");
kfree(host);
return -EIO; return -EIO;
} }
@ -212,7 +208,6 @@ static int socrates_nand_probe(struct platform_device *ofdev)
out: out:
iounmap(host->io_base); iounmap(host->io_base);
kfree(host);
return res; return res;
} }
@ -227,7 +222,6 @@ static int socrates_nand_remove(struct platform_device *ofdev)
nand_release(mtd); nand_release(mtd);
iounmap(host->io_base); iounmap(host->io_base);
kfree(host);
return 0; return 0;
} }