mtd: socrates_nand: Use devm_kzalloc
authorSachin Kamat <sachin.kamat@linaro.org>
Tue, 8 Oct 2013 10:01:46 +0000 (15:31 +0530)
committerBrian Norris <computersforpeace@gmail.com>
Thu, 7 Nov 2013 07:32:50 +0000 (23:32 -0800)
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>
drivers/mtd/nand/socrates_nand.c

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