diff options
author | Florian Fainelli <florian.fainelli@telecomint.eu> | 2008-03-03 12:30:24 -0500 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2008-04-22 15:10:10 -0400 |
commit | 757570063a350ee3875c42a6338d29ee09f5af07 (patch) | |
tree | 2a6b9e9353312b4f69d62af5dc052e13dd009fb7 /drivers | |
parent | ca5c23c3b8882d61bf19b7685f2244501902869f (diff) |
[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: Florian Fainelli <florian.fainelli@telecomint.eu>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/maps/plat-ram.c | 47 |
1 files changed, 32 insertions, 15 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: |