Commit e062e2f5 authored by Dmitry Eremin-Solenikov's avatar Dmitry Eremin-Solenikov Committed by Artem Bityutskiy

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: default avatarDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 7029eef8
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <asm/immap_cpm2.h> #include <asm/immap_cpm2.h>
static struct mtd_info *sbcmtd[3]; static struct mtd_info *sbcmtd[3];
static struct mtd_partition *sbcmtd_parts[3];
struct map_info sbc82xx_flash_map[3] = { struct map_info sbc82xx_flash_map[3] = {
{.name = "Boot flash"}, {.name = "Boot flash"},
...@@ -101,6 +100,7 @@ static int __init init_sbc82xx_flash(void) ...@@ -101,6 +100,7 @@ static int __init init_sbc82xx_flash(void)
for (i=0; i<3; i++) { for (i=0; i<3; i++) {
int8_t flashcs[3] = { 0, 6, 1 }; int8_t flashcs[3] = { 0, 6, 1 };
int nr_parts; int nr_parts;
struct mtd_partition *defparts;
printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d", printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d",
sbc82xx_flash_map[i].name, sbc82xx_flash_map[i].name,
...@@ -113,7 +113,8 @@ static int __init init_sbc82xx_flash(void) ...@@ -113,7 +113,8 @@ static int __init init_sbc82xx_flash(void)
} }
printk(" at %08lx)\n", sbc82xx_flash_map[i].phys); printk(" at %08lx)\n", sbc82xx_flash_map[i].phys);
sbc82xx_flash_map[i].virt = ioremap(sbc82xx_flash_map[i].phys, sbc82xx_flash_map[i].size); sbc82xx_flash_map[i].virt = ioremap(sbc82xx_flash_map[i].phys,
sbc82xx_flash_map[i].size);
if (!sbc82xx_flash_map[i].virt) { if (!sbc82xx_flash_map[i].virt) {
printk("Failed to ioremap\n"); printk("Failed to ioremap\n");
...@@ -129,24 +130,20 @@ static int __init init_sbc82xx_flash(void) ...@@ -129,24 +130,20 @@ static int __init init_sbc82xx_flash(void)
sbcmtd[i]->owner = THIS_MODULE; sbcmtd[i]->owner = THIS_MODULE;
nr_parts = parse_mtd_partitions(sbcmtd[i], part_probes,
&sbcmtd_parts[i], 0);
if (nr_parts > 0) {
mtd_device_register(sbcmtd[i], sbcmtd_parts[i],
nr_parts);
continue;
}
/* No partitioning detected. Use default */ /* No partitioning detected. Use default */
if (i == 2) { if (i == 2) {
mtd_device_register(sbcmtd[i], NULL, 0); defparts = NULL;
nr_parts = 0;
} else if (i == bigflash) { } else if (i == bigflash) {
mtd_device_register(sbcmtd[i], bigflash_parts, defparts = bigflash_parts;
ARRAY_SIZE(bigflash_parts)); nr_parts = ARRAY_SIZE(bigflash_parts);
} else { } else {
mtd_device_register(sbcmtd[i], smallflash_parts, defparts = smallflash_parts;
ARRAY_SIZE(smallflash_parts)); nr_parts = ARRAY_SIZE(smallflash_parts);
} }
mtd_device_parse_register(sbcmtd[i], part_probes, 0,
defparts, nr_parts);
} }
return 0; return 0;
} }
...@@ -159,12 +156,8 @@ static void __exit cleanup_sbc82xx_flash(void) ...@@ -159,12 +156,8 @@ static void __exit cleanup_sbc82xx_flash(void)
if (!sbcmtd[i]) if (!sbcmtd[i])
continue; continue;
if (i<2 || sbcmtd_parts[i]) mtd_device_unregister(sbcmtd[i]);
mtd_device_unregister(sbcmtd[i]);
else
mtd_device_unregister(sbcmtd[i]);
kfree(sbcmtd_parts[i]);
map_destroy(sbcmtd[i]); map_destroy(sbcmtd[i]);
iounmap((void *)sbc82xx_flash_map[i].virt); iounmap((void *)sbc82xx_flash_map[i].virt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment