Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: wr_sbc82xx_flash.c: use mtd_device_parse_register

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.

Artem: some tweaks, split one very long line while on it.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

authored by

Dmitry Eremin-Solenikov and committed by
Artem Bityutskiy
e062e2f5 7029eef8

+13 -20
+13 -20
drivers/mtd/maps/wr_sbc82xx_flash.c
··· 20 20 #include <asm/immap_cpm2.h> 21 21 22 22 static struct mtd_info *sbcmtd[3]; 23 - static struct mtd_partition *sbcmtd_parts[3]; 24 23 25 24 struct map_info sbc82xx_flash_map[3] = { 26 25 {.name = "Boot flash"}, ··· 100 101 for (i=0; i<3; i++) { 101 102 int8_t flashcs[3] = { 0, 6, 1 }; 102 103 int nr_parts; 104 + struct mtd_partition *defparts; 103 105 104 106 printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d", 105 107 sbc82xx_flash_map[i].name, ··· 113 113 } 114 114 printk(" at %08lx)\n", sbc82xx_flash_map[i].phys); 115 115 116 - sbc82xx_flash_map[i].virt = ioremap(sbc82xx_flash_map[i].phys, sbc82xx_flash_map[i].size); 116 + sbc82xx_flash_map[i].virt = ioremap(sbc82xx_flash_map[i].phys, 117 + sbc82xx_flash_map[i].size); 117 118 118 119 if (!sbc82xx_flash_map[i].virt) { 119 120 printk("Failed to ioremap\n"); ··· 130 129 131 130 sbcmtd[i]->owner = THIS_MODULE; 132 131 133 - nr_parts = parse_mtd_partitions(sbcmtd[i], part_probes, 134 - &sbcmtd_parts[i], 0); 135 - if (nr_parts > 0) { 136 - mtd_device_register(sbcmtd[i], sbcmtd_parts[i], 137 - nr_parts); 138 - continue; 139 - } 140 - 141 132 /* No partitioning detected. Use default */ 142 133 if (i == 2) { 143 - mtd_device_register(sbcmtd[i], NULL, 0); 134 + defparts = NULL; 135 + nr_parts = 0; 144 136 } else if (i == bigflash) { 145 - mtd_device_register(sbcmtd[i], bigflash_parts, 146 - ARRAY_SIZE(bigflash_parts)); 137 + defparts = bigflash_parts; 138 + nr_parts = ARRAY_SIZE(bigflash_parts); 147 139 } else { 148 - mtd_device_register(sbcmtd[i], smallflash_parts, 149 - ARRAY_SIZE(smallflash_parts)); 140 + defparts = smallflash_parts; 141 + nr_parts = ARRAY_SIZE(smallflash_parts); 150 142 } 143 + 144 + mtd_device_parse_register(sbcmtd[i], part_probes, 0, 145 + defparts, nr_parts); 151 146 } 152 147 return 0; 153 148 } ··· 156 159 if (!sbcmtd[i]) 157 160 continue; 158 161 159 - if (i<2 || sbcmtd_parts[i]) 160 - mtd_device_unregister(sbcmtd[i]); 161 - else 162 - mtd_device_unregister(sbcmtd[i]); 162 + mtd_device_unregister(sbcmtd[i]); 163 163 164 - kfree(sbcmtd_parts[i]); 165 164 map_destroy(sbcmtd[i]); 166 165 167 166 iounmap((void *)sbc82xx_flash_map[i].virt);