mtd: plat_nand.c: use mtd_device_parse_register
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Thu, 2 Jun 2011 14:00:57 +0000 (18:00 +0400)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Sun, 11 Sep 2011 12:02:09 +0000 (15:02 +0300)
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
drivers/mtd/nand/plat_nand.c

index 746a723b49332c2ccf4ba5d8c46dd486dfe95942..ea8e1234e0e25895ed2a731ae1a0225d616468fa 100644 (file)
@@ -21,8 +21,6 @@ struct plat_nand_data {
        struct nand_chip        chip;
        struct mtd_info         mtd;
        void __iomem            *io_base;
-       int                     nr_parts;
-       struct mtd_partition    *parts;
 };
 
 /*
@@ -100,21 +98,9 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
                goto out;
        }
 
-       if (pdata->chip.part_probe_types) {
-               err = parse_mtd_partitions(&data->mtd,
-                                       pdata->chip.part_probe_types,
-                                       &data->parts, 0);
-               if (err > 0) {
-                       mtd_device_register(&data->mtd, data->parts, err);
-                       return 0;
-               }
-       }
-       if (pdata->chip.partitions) {
-               data->parts = pdata->chip.partitions;
-               err = mtd_device_register(&data->mtd, data->parts,
-                       pdata->chip.nr_partitions);
-       } else
-               err = mtd_device_register(&data->mtd, NULL, 0);
+       err = mtd_device_parse_register(&data->mtd,
+                       pdata->chip.part_probe_types, 0,
+                       pdata->chip.partitions, pdata->chip.nr_partitions);
 
        if (!err)
                return err;
@@ -144,8 +130,6 @@ static int __devexit plat_nand_remove(struct platform_device *pdev)
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
        nand_release(&data->mtd);
-       if (data->parts && data->parts != pdata->chip.partitions)
-               kfree(data->parts);
        if (pdata->ctrl.remove)
                pdata->ctrl.remove(pdev);
        iounmap(data->io_base);