diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2011-06-02 10:00:20 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2011-09-11 08:02:07 -0400 |
commit | e062e2f52fed5bcf65b3228e991771a4a6030d85 (patch) | |
tree | fe6fd245be4c14b58fdfd2c4852d12363815a228 /drivers/mtd/maps/wr_sbc82xx_flash.c | |
parent | 7029eef8ba6ebf96c18c4b3138c35fcd1342a80a (diff) |
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>
Diffstat (limited to 'drivers/mtd/maps/wr_sbc82xx_flash.c')
-rw-r--r-- | drivers/mtd/maps/wr_sbc82xx_flash.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/drivers/mtd/maps/wr_sbc82xx_flash.c b/drivers/mtd/maps/wr_sbc82xx_flash.c index 901ce968efae..aa7e0cb2893c 100644 --- a/drivers/mtd/maps/wr_sbc82xx_flash.c +++ b/drivers/mtd/maps/wr_sbc82xx_flash.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <asm/immap_cpm2.h> | 20 | #include <asm/immap_cpm2.h> |
21 | 21 | ||
22 | static struct mtd_info *sbcmtd[3]; | 22 | static struct mtd_info *sbcmtd[3]; |
23 | static struct mtd_partition *sbcmtd_parts[3]; | ||
24 | 23 | ||
25 | struct map_info sbc82xx_flash_map[3] = { | 24 | struct map_info sbc82xx_flash_map[3] = { |
26 | {.name = "Boot flash"}, | 25 | {.name = "Boot flash"}, |
@@ -101,6 +100,7 @@ static int __init init_sbc82xx_flash(void) | |||
101 | for (i=0; i<3; i++) { | 100 | for (i=0; i<3; i++) { |
102 | int8_t flashcs[3] = { 0, 6, 1 }; | 101 | int8_t flashcs[3] = { 0, 6, 1 }; |
103 | int nr_parts; | 102 | int nr_parts; |
103 | struct mtd_partition *defparts; | ||
104 | 104 | ||
105 | printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d", | 105 | printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d", |
106 | sbc82xx_flash_map[i].name, | 106 | sbc82xx_flash_map[i].name, |
@@ -113,7 +113,8 @@ static int __init init_sbc82xx_flash(void) | |||
113 | } | 113 | } |
114 | printk(" at %08lx)\n", sbc82xx_flash_map[i].phys); | 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 | if (!sbc82xx_flash_map[i].virt) { | 119 | if (!sbc82xx_flash_map[i].virt) { |
119 | printk("Failed to ioremap\n"); | 120 | printk("Failed to ioremap\n"); |
@@ -129,24 +130,20 @@ static int __init init_sbc82xx_flash(void) | |||
129 | 130 | ||
130 | sbcmtd[i]->owner = THIS_MODULE; | 131 | sbcmtd[i]->owner = THIS_MODULE; |
131 | 132 | ||
132 | nr_parts = parse_mtd_partitions(sbcmtd[i], part_probes, | ||
133 | &sbcmtd_parts[i], 0); | ||
134 | if (nr_parts > 0) { | ||
135 | mtd_device_register(sbcmtd[i], sbcmtd_parts[i], | ||
136 | nr_parts); | ||
137 | continue; | ||
138 | } | ||
139 | |||
140 | /* No partitioning detected. Use default */ | 133 | /* No partitioning detected. Use default */ |
141 | if (i == 2) { | 134 | if (i == 2) { |
142 | mtd_device_register(sbcmtd[i], NULL, 0); | 135 | defparts = NULL; |
136 | nr_parts = 0; | ||
143 | } else if (i == bigflash) { | 137 | } else if (i == bigflash) { |
144 | mtd_device_register(sbcmtd[i], bigflash_parts, | 138 | defparts = bigflash_parts; |
145 | ARRAY_SIZE(bigflash_parts)); | 139 | nr_parts = ARRAY_SIZE(bigflash_parts); |
146 | } else { | 140 | } else { |
147 | mtd_device_register(sbcmtd[i], smallflash_parts, | 141 | defparts = smallflash_parts; |
148 | ARRAY_SIZE(smallflash_parts)); | 142 | nr_parts = ARRAY_SIZE(smallflash_parts); |
149 | } | 143 | } |
144 | |||
145 | mtd_device_parse_register(sbcmtd[i], part_probes, 0, | ||
146 | defparts, nr_parts); | ||
150 | } | 147 | } |
151 | return 0; | 148 | return 0; |
152 | } | 149 | } |
@@ -159,12 +156,8 @@ static void __exit cleanup_sbc82xx_flash(void) | |||
159 | if (!sbcmtd[i]) | 156 | if (!sbcmtd[i]) |
160 | continue; | 157 | continue; |
161 | 158 | ||
162 | if (i<2 || sbcmtd_parts[i]) | 159 | mtd_device_unregister(sbcmtd[i]); |
163 | mtd_device_unregister(sbcmtd[i]); | ||
164 | else | ||
165 | mtd_device_unregister(sbcmtd[i]); | ||
166 | 160 | ||
167 | kfree(sbcmtd_parts[i]); | ||
168 | map_destroy(sbcmtd[i]); | 161 | map_destroy(sbcmtd[i]); |
169 | 162 | ||
170 | iounmap((void *)sbc82xx_flash_map[i].virt); | 163 | iounmap((void *)sbc82xx_flash_map[i].virt); |