Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93034
b: refs/heads/master
c: 7575700
h: refs/heads/master
v: v3
  • Loading branch information
Florian Fainelli authored and David Woodhouse committed Apr 22, 2008
1 parent edf752d commit 6260671
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca5c23c3b8882d61bf19b7685f2244501902869f
refs/heads/master: 757570063a350ee3875c42a6338d29ee09f5af07
47 changes: 32 additions & 15 deletions trunk/drivers/mtd/maps/plat-ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct platram_info {
struct mtd_info *mtd;
struct map_info map;
struct mtd_partition *partitions;
bool free_partitions;
struct resource *area;
struct platdata_mtd_ram *pdata;
};
Expand Down Expand Up @@ -98,7 +99,8 @@ static int platram_remove(struct platform_device *pdev)
#ifdef CONFIG_MTD_PARTITIONS
if (info->partitions) {
del_mtd_partitions(info->mtd);
kfree(info->partitions);
if (info->free_partitions)
kfree(info->partitions);
}
#endif
del_mtd_device(info->mtd);
Expand Down Expand Up @@ -176,7 +178,8 @@ static int platram_probe(struct platform_device *pdev)

info->map.phys = res->start;
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;

/* register our usage of the memory area */
Expand All @@ -203,9 +206,19 @@ static int platram_probe(struct platform_device *pdev)

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) {
dev_err(&pdev->dev, "failed to probe for map_ram\n");
err = -ENOMEM;
Expand All @@ -220,27 +233,31 @@ static int platram_probe(struct platform_device *pdev)
* to add this device whole */

#ifdef CONFIG_MTD_PARTITIONS
if (pdata->nr_partitions > 0) {
const char **probes = { NULL };

if (pdata->probes)
probes = (const char **)pdata->probes;

err = parse_mtd_partitions(info->mtd, probes,
if (!pdata->nr_partitions) {
/* try to probe using the supplied probe type */
if (pdata->probes) {
err = parse_mtd_partitions(info->mtd, pdata->probes,
&info->partitions, 0);
if (err > 0) {
err = add_mtd_partitions(info->mtd, info->partitions,
err);
info->free_partitions = 1;
if (err > 0)
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 */

if (add_mtd_device(info->mtd)) {
dev_err(&pdev->dev, "add_mtd_device() failed\n");
err = -ENOMEM;
}

dev_info(&pdev->dev, "registered mtd device\n");
if (!err)
dev_info(&pdev->dev, "registered mtd device\n");

return err;

exit_free:
Expand Down
5 changes: 3 additions & 2 deletions trunk/include/linux/mtd/plat-ram.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
#define PLATRAM_RW (1)

struct platdata_mtd_ram {
char *mapname;
char **probes;
const char *mapname;
const char **map_probes;
const char **probes;
struct mtd_partition *partitions;
int nr_partitions;
int bankwidth;
Expand Down

0 comments on commit 6260671

Please sign in to comment.