mtd: plat-ram.c: use mtd_device_parse_register
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Thu, 2 Jun 2011 14:00:01 +0000 (18:00 +0400)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Sun, 11 Sep 2011 12:02:07 +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/maps/plat-ram.c

index 9ca1eccba4bc2e70b0d5e7ea6c3be5d014f6da5e..94f553489725280d2ec851023f17745e86c48d9a 100644 (file)
@@ -44,8 +44,6 @@ struct platram_info {
        struct device           *dev;
        struct mtd_info         *mtd;
        struct map_info          map;
-       struct mtd_partition    *partitions;
-       bool                    free_partitions;
        struct resource         *area;
        struct platdata_mtd_ram *pdata;
 };
@@ -95,10 +93,6 @@ static int platram_remove(struct platform_device *pdev)
 
        if (info->mtd) {
                mtd_device_unregister(info->mtd);
-               if (info->partitions) {
-                       if (info->free_partitions)
-                               kfree(info->partitions);
-               }
                map_destroy(info->mtd);
        }
 
@@ -228,21 +222,8 @@ static int platram_probe(struct platform_device *pdev)
        /* check to see if there are any available partitions, or wether
         * to add this device whole */
 
-       if (!pdata->nr_partitions) {
-               /* try to probe using the supplied probe type */
-               if (pdata->probes) {
-                       err = parse_mtd_partitions(info->mtd, pdata->probes,
-                                          &info->partitions, 0);
-                       info->free_partitions = 1;
-                       if (err > 0)
-                               err = mtd_device_register(info->mtd,
-                                       info->partitions, err);
-               }
-       }
-       /* use the static mapping */
-       else
-               err = mtd_device_register(info->mtd, pdata->partitions,
-                                         pdata->nr_partitions);
+       err = mtd_device_parse_register(info->mtd, pdata->probes, 0,
+                       pdata->partitions, pdata->nr_partitions);
        if (!err)
                dev_info(&pdev->dev, "registered mtd device\n");