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

mtd: impa7.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: rename static_partitions to make lines shorter and align the way
this driver prefers.

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
5003403b 8db2a08e

+4 -23
+4 -23
drivers/mtd/maps/impa7.c
··· 49 49 /* 50 50 * MTD partitioning stuff 51 51 */ 52 - static struct mtd_partition static_partitions[] = 52 + static struct mtd_partition partitions[] = 53 53 { 54 54 { 55 55 .name = "FileSystem", ··· 58 58 }, 59 59 }; 60 60 61 - static int mtd_parts_nb[NUM_FLASHBANKS]; 62 - static struct mtd_partition *mtd_parts[NUM_FLASHBANKS]; 63 - 64 - 65 61 static int __init init_impa7(void) 66 62 { 67 63 static const char *rom_probe_types[] = PROBETYPES; 68 64 const char **type; 69 - const char *part_type = 0; 70 65 int i; 71 66 static struct { u_long addr; u_long size; } pt[NUM_FLASHBANKS] = { 72 67 { WINDOW_ADDR0, WINDOW_SIZE0 }, ··· 91 96 if (impa7_mtd[i]) { 92 97 impa7_mtd[i]->owner = THIS_MODULE; 93 98 devicesfound++; 94 - mtd_parts_nb[i] = parse_mtd_partitions(impa7_mtd[i], 95 - NULL, 96 - &mtd_parts[i], 97 - 0); 98 - if (mtd_parts_nb[i] > 0) { 99 - part_type = "command line"; 100 - } else { 101 - mtd_parts[i] = static_partitions; 102 - mtd_parts_nb[i] = ARRAY_SIZE(static_partitions); 103 - part_type = "static"; 104 - } 105 - 106 - printk(KERN_NOTICE MSG_PREFIX 107 - "using %s partition definition\n", 108 - part_type); 109 - mtd_device_register(impa7_mtd[i], 110 - mtd_parts[i], mtd_parts_nb[i]); 99 + mtd_device_parse_register(impa7_mtd[i], NULL, 0, 100 + partitions, 101 + ARRAY_SIZE(partitions)); 111 102 } 112 103 else 113 104 iounmap((void *)impa7_map[i].virt);