aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/maps/plat-ram.c47
-rw-r--r--include/linux/mtd/plat-ram.h5
2 files changed, 35 insertions, 17 deletions
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index 7160e0eb09af..f0b10ca05029 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -47,6 +47,7 @@ struct platram_info {
47 struct mtd_info *mtd; 47 struct mtd_info *mtd;
48 struct map_info map; 48 struct map_info map;
49 struct mtd_partition *partitions; 49 struct mtd_partition *partitions;
50 bool free_partitions;
50 struct resource *area; 51 struct resource *area;
51 struct platdata_mtd_ram *pdata; 52 struct platdata_mtd_ram *pdata;
52}; 53};
@@ -98,7 +99,8 @@ static int platram_remove(struct platform_device *pdev)
98#ifdef CONFIG_MTD_PARTITIONS 99#ifdef CONFIG_MTD_PARTITIONS
99 if (info->partitions) { 100 if (info->partitions) {
100 del_mtd_partitions(info->mtd); 101 del_mtd_partitions(info->mtd);
101 kfree(info->partitions); 102 if (info->free_partitions)
103 kfree(info->partitions);
102 } 104 }
103#endif 105#endif
104 del_mtd_device(info->mtd); 106 del_mtd_device(info->mtd);
@@ -176,7 +178,8 @@ static int platram_probe(struct platform_device *pdev)
176 178
177 info->map.phys = res->start; 179 info->map.phys = res->start;
178 info->map.size = (res->end - res->start) + 1; 180 info->map.size = (res->end - res->start) + 1;
179 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pdev->name; 181 info->map.name = pdata->mapname != NULL ?
182 (char *)pdata->mapname : (char *)pdev->name;
180 info->map.bankwidth = pdata->bankwidth; 183 info->map.bankwidth = pdata->bankwidth;
181 184
182 /* register our usage of the memory area */ 185 /* register our usage of the memory area */
@@ -203,9 +206,19 @@ static int platram_probe(struct platform_device *pdev)
203 206
204 dev_dbg(&pdev->dev, "initialised map, probing for mtd\n"); 207 dev_dbg(&pdev->dev, "initialised map, probing for mtd\n");
205 208
206 /* probe for the right mtd map driver */ 209 /* probe for the right mtd map driver
210 * supplied by the platform_data struct */
211
212 if (pdata->map_probes != 0) {
213 const char **map_probes = pdata->map_probes;
214
215 for ( ; !info->mtd && *map_probes; map_probes++)
216 info->mtd = do_map_probe(*map_probes , &info->map);
217 }
218 /* fallback to map_ram */
219 else
220 info->mtd = do_map_probe("map_ram", &info->map);
207 221
208 info->mtd = do_map_probe("map_ram" , &info->map);
209 if (info->mtd == NULL) { 222 if (info->mtd == NULL) {
210 dev_err(&pdev->dev, "failed to probe for map_ram\n"); 223 dev_err(&pdev->dev, "failed to probe for map_ram\n");
211 err = -ENOMEM; 224 err = -ENOMEM;
@@ -220,19 +233,21 @@ static int platram_probe(struct platform_device *pdev)
220 * to add this device whole */ 233 * to add this device whole */
221 234
222#ifdef CONFIG_MTD_PARTITIONS 235#ifdef CONFIG_MTD_PARTITIONS
223 if (pdata->nr_partitions > 0) { 236 if (!pdata->nr_partitions) {
224 const char **probes = { NULL }; 237 /* try to probe using the supplied probe type */
225 238 if (pdata->probes) {
226 if (pdata->probes) 239 err = parse_mtd_partitions(info->mtd, pdata->probes,
227 probes = (const char **)pdata->probes;
228
229 err = parse_mtd_partitions(info->mtd, probes,
230 &info->partitions, 0); 240 &info->partitions, 0);
231 if (err > 0) { 241 info->free_partitions = 1;
232 err = add_mtd_partitions(info->mtd, info->partitions, 242 if (err > 0)
233 err); 243 err = add_mtd_partitions(info->mtd,
244 info->partitions, err);
234 } 245 }
235 } 246 }
247 /* use the static mapping */
248 else
249 err = add_mtd_partitions(info->mtd, pdata->partitions,
250 pdata->nr_partitions);
236#endif /* CONFIG_MTD_PARTITIONS */ 251#endif /* CONFIG_MTD_PARTITIONS */
237 252
238 if (add_mtd_device(info->mtd)) { 253 if (add_mtd_device(info->mtd)) {
@@ -240,7 +255,9 @@ static int platram_probe(struct platform_device *pdev)
240 err = -ENOMEM; 255 err = -ENOMEM;
241 } 256 }
242 257
243 dev_info(&pdev->dev, "registered mtd device\n"); 258 if (!err)
259 dev_info(&pdev->dev, "registered mtd device\n");
260
244 return err; 261 return err;
245 262
246 exit_free: 263 exit_free:
diff --git a/include/linux/mtd/plat-ram.h b/include/linux/mtd/plat-ram.h
index 9667863bd7e3..0e37ad07bce2 100644
--- a/include/linux/mtd/plat-ram.h
+++ b/include/linux/mtd/plat-ram.h
@@ -21,8 +21,9 @@
21#define PLATRAM_RW (1) 21#define PLATRAM_RW (1)
22 22
23struct platdata_mtd_ram { 23struct platdata_mtd_ram {
24 char *mapname; 24 const char *mapname;
25 char **probes; 25 const char **map_probes;
26 const char **probes;
26 struct mtd_partition *partitions; 27 struct mtd_partition *partitions;
27 int nr_partitions; 28 int nr_partitions;
28 int bankwidth; 29 int bankwidth;