Commit 75757006 authored by Florian Fainelli's avatar Florian Fainelli Committed by David Woodhouse

[MTD] [MAPS] Extend plat-ram to support a supplied probe type

This enhances plat-ram to take a map_probes argument in
the platform_data structure which allow plat-ram to support
any direct-mapped device that MTD supports (jedec, cfi, amd ..)

A few items are also fixed:
- Don't panic if probes is 0
- Actually use the partition list that is passed in
Signed-off-by: default avatarFlorian Fainelli <florian.fainelli@telecomint.eu>
Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent ca5c23c3
...@@ -47,6 +47,7 @@ struct platram_info { ...@@ -47,6 +47,7 @@ struct platram_info {
struct mtd_info *mtd; struct mtd_info *mtd;
struct map_info map; struct map_info map;
struct mtd_partition *partitions; struct mtd_partition *partitions;
bool free_partitions;
struct resource *area; struct resource *area;
struct platdata_mtd_ram *pdata; struct platdata_mtd_ram *pdata;
}; };
...@@ -98,7 +99,8 @@ static int platram_remove(struct platform_device *pdev) ...@@ -98,7 +99,8 @@ static int platram_remove(struct platform_device *pdev)
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
if (info->partitions) { if (info->partitions) {
del_mtd_partitions(info->mtd); del_mtd_partitions(info->mtd);
kfree(info->partitions); if (info->free_partitions)
kfree(info->partitions);
} }
#endif #endif
del_mtd_device(info->mtd); del_mtd_device(info->mtd);
...@@ -176,7 +178,8 @@ static int platram_probe(struct platform_device *pdev) ...@@ -176,7 +178,8 @@ static int platram_probe(struct platform_device *pdev)
info->map.phys = res->start; info->map.phys = res->start;
info->map.size = (res->end - res->start) + 1; info->map.size = (res->end - res->start) + 1;
info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pdev->name; info->map.name = pdata->mapname != NULL ?
(char *)pdata->mapname : (char *)pdev->name;
info->map.bankwidth = pdata->bankwidth; info->map.bankwidth = pdata->bankwidth;
/* register our usage of the memory area */ /* register our usage of the memory area */
...@@ -203,9 +206,19 @@ static int platram_probe(struct platform_device *pdev) ...@@ -203,9 +206,19 @@ static int platram_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "initialised map, probing for mtd\n"); dev_dbg(&pdev->dev, "initialised map, probing for mtd\n");
/* probe for the right mtd map driver */ /* probe for the right mtd map driver
* supplied by the platform_data struct */
if (pdata->map_probes != 0) {
const char **map_probes = pdata->map_probes;
for ( ; !info->mtd && *map_probes; map_probes++)
info->mtd = do_map_probe(*map_probes , &info->map);
}
/* fallback to map_ram */
else
info->mtd = do_map_probe("map_ram", &info->map);
info->mtd = do_map_probe("map_ram" , &info->map);
if (info->mtd == NULL) { if (info->mtd == NULL) {
dev_err(&pdev->dev, "failed to probe for map_ram\n"); dev_err(&pdev->dev, "failed to probe for map_ram\n");
err = -ENOMEM; err = -ENOMEM;
...@@ -220,19 +233,21 @@ static int platram_probe(struct platform_device *pdev) ...@@ -220,19 +233,21 @@ static int platram_probe(struct platform_device *pdev)
* to add this device whole */ * to add this device whole */
#ifdef CONFIG_MTD_PARTITIONS #ifdef CONFIG_MTD_PARTITIONS
if (pdata->nr_partitions > 0) { if (!pdata->nr_partitions) {
const char **probes = { NULL }; /* try to probe using the supplied probe type */
if (pdata->probes) {
if (pdata->probes) err = parse_mtd_partitions(info->mtd, pdata->probes,
probes = (const char **)pdata->probes;
err = parse_mtd_partitions(info->mtd, probes,
&info->partitions, 0); &info->partitions, 0);
if (err > 0) { info->free_partitions = 1;
err = add_mtd_partitions(info->mtd, info->partitions, if (err > 0)
err); err = add_mtd_partitions(info->mtd,
info->partitions, err);
} }
} }
/* use the static mapping */
else
err = add_mtd_partitions(info->mtd, pdata->partitions,
pdata->nr_partitions);
#endif /* CONFIG_MTD_PARTITIONS */ #endif /* CONFIG_MTD_PARTITIONS */
if (add_mtd_device(info->mtd)) { if (add_mtd_device(info->mtd)) {
...@@ -240,7 +255,9 @@ static int platram_probe(struct platform_device *pdev) ...@@ -240,7 +255,9 @@ static int platram_probe(struct platform_device *pdev)
err = -ENOMEM; err = -ENOMEM;
} }
dev_info(&pdev->dev, "registered mtd device\n"); if (!err)
dev_info(&pdev->dev, "registered mtd device\n");
return err; return err;
exit_free: exit_free:
......
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
#define PLATRAM_RW (1) #define PLATRAM_RW (1)
struct platdata_mtd_ram { struct platdata_mtd_ram {
char *mapname; const char *mapname;
char **probes; const char **map_probes;
const char **probes;
struct mtd_partition *partitions; struct mtd_partition *partitions;
int nr_partitions; int nr_partitions;
int bankwidth; int bankwidth;
......
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