mtd: solutionengine.c: use mtd_device_parse_register
[firefly-linux-kernel-4.4.55.git] / drivers / mtd / maps / solutionengine.c
index 0eb41d9c67867fb90280ba0570408e1536b4760e..496c40704aff6567dcd7546b0cb9c87742222263 100644 (file)
@@ -19,8 +19,6 @@
 static struct mtd_info *flash_mtd;
 static struct mtd_info *eprom_mtd;
 
-static struct mtd_partition *parsed_parts;
-
 struct map_info soleng_eprom_map = {
        .name = "Solution Engine EPROM",
        .size = 0x400000,
@@ -51,12 +49,14 @@ static struct mtd_partition superh_se_partitions[] = {
                .size = MTDPART_SIZ_FULL,
        }
 };
+#define NUM_PARTITIONS ARRAY_SIZE(superh_se_partitions)
+#else
+#define superh_se_partitions NULL
+#define NUM_PARTITIONS 0
 #endif /* CONFIG_MTD_SUPERH_RESERVE */
 
 static int __init init_soleng_maps(void)
 {
-       int nr_parts = 0;
-
        /* First probe at offset 0 */
        soleng_flash_map.phys = 0;
        soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0);
@@ -89,24 +89,11 @@ static int __init init_soleng_maps(void)
        eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
        if (eprom_mtd) {
                eprom_mtd->owner = THIS_MODULE;
-               add_mtd_device(eprom_mtd);
+               mtd_device_register(eprom_mtd, NULL, 0);
        }
 
-       nr_parts = parse_mtd_partitions(flash_mtd, probes, &parsed_parts, 0);
-
-#ifdef CONFIG_MTD_SUPERH_RESERVE
-       if (nr_parts <= 0) {
-               printk(KERN_NOTICE "Using configured partition at 0x%08x.\n",
-                      CONFIG_MTD_SUPERH_RESERVE);
-               parsed_parts = superh_se_partitions;
-               nr_parts = sizeof(superh_se_partitions)/sizeof(*parsed_parts);
-       }
-#endif /* CONFIG_MTD_SUPERH_RESERVE */
-
-       if (nr_parts > 0)
-               add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
-       else
-               add_mtd_device(flash_mtd);
+       mtd_device_parse_register(flash_mtd, probes, 0,
+                       superh_se_partitions, NUM_PARTITIONS);
 
        return 0;
 }
@@ -114,14 +101,11 @@ static int __init init_soleng_maps(void)
 static void __exit cleanup_soleng_maps(void)
 {
        if (eprom_mtd) {
-               del_mtd_device(eprom_mtd);
+               mtd_device_unregister(eprom_mtd);
                map_destroy(eprom_mtd);
        }
 
-       if (parsed_parts)
-               del_mtd_partitions(flash_mtd);
-       else
-               del_mtd_device(flash_mtd);
+       mtd_device_unregister(flash_mtd);
        map_destroy(flash_mtd);
 }