Commit ba52f3a2 authored by Jamie Iles's avatar Jamie Iles Committed by David Woodhouse

mtd: m25p80: convert to mtd_device_register()

Convert to mtd_device_register() and remove the CONFIG_MTD_PARTITIONS
preprocessor conditionals as partitioning is always available.
Signed-off-by: default avatarJamie Iles <jamie@jamieiles.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 711a632d
...@@ -825,6 +825,8 @@ static int __devinit m25p_probe(struct spi_device *spi) ...@@ -825,6 +825,8 @@ static int __devinit m25p_probe(struct spi_device *spi)
struct m25p *flash; struct m25p *flash;
struct flash_info *info; struct flash_info *info;
unsigned i; unsigned i;
struct mtd_partition *parts = NULL;
int nr_parts = 0;
/* Platform data helps sort out which chip type we have, as /* Platform data helps sort out which chip type we have, as
* well as how this board partitions it. If we don't have * well as how this board partitions it. If we don't have
...@@ -966,48 +968,41 @@ static int __devinit m25p_probe(struct spi_device *spi) ...@@ -966,48 +968,41 @@ static int __devinit m25p_probe(struct spi_device *spi)
/* partitions should match sector boundaries; and it may be good to /* partitions should match sector boundaries; and it may be good to
* use readonly partitions for writeprotected sectors (BP2..BP0). * use readonly partitions for writeprotected sectors (BP2..BP0).
*/ */
if (mtd_has_partitions()) { if (mtd_has_cmdlinepart()) {
struct mtd_partition *parts = NULL; static const char *part_probes[]
int nr_parts = 0; = { "cmdlinepart", NULL, };
if (mtd_has_cmdlinepart()) { nr_parts = parse_mtd_partitions(&flash->mtd,
static const char *part_probes[] part_probes, &parts, 0);
= { "cmdlinepart", NULL, }; }
nr_parts = parse_mtd_partitions(&flash->mtd,
part_probes, &parts, 0);
}
if (nr_parts <= 0 && data && data->parts) { if (nr_parts <= 0 && data && data->parts) {
parts = data->parts; parts = data->parts;
nr_parts = data->nr_parts; nr_parts = data->nr_parts;
} }
#ifdef CONFIG_MTD_OF_PARTS #ifdef CONFIG_MTD_OF_PARTS
if (nr_parts <= 0 && spi->dev.of_node) { if (nr_parts <= 0 && spi->dev.of_node) {
nr_parts = of_mtd_parse_partitions(&spi->dev, nr_parts = of_mtd_parse_partitions(&spi->dev,
spi->dev.of_node, &parts); spi->dev.of_node, &parts);
} }
#endif #endif
if (nr_parts > 0) { if (nr_parts > 0) {
for (i = 0; i < nr_parts; i++) { for (i = 0; i < nr_parts; i++) {
DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
"{.name = %s, .offset = 0x%llx, " "{.name = %s, .offset = 0x%llx, "
".size = 0x%llx (%lldKiB) }\n", ".size = 0x%llx (%lldKiB) }\n",
i, parts[i].name, i, parts[i].name,
(long long)parts[i].offset, (long long)parts[i].offset,
(long long)parts[i].size, (long long)parts[i].size,
(long long)(parts[i].size >> 10)); (long long)(parts[i].size >> 10));
}
flash->partitioned = 1;
return add_mtd_partitions(&flash->mtd, parts, nr_parts);
} }
} else if (data && data->nr_parts) flash->partitioned = 1;
dev_warn(&spi->dev, "ignoring %d default partitions on %s\n", }
data->nr_parts, data->name);
return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0; return mtd_device_register(&flash->mtd, parts, nr_parts) == 1 ?
-ENODEV : 0;
} }
...@@ -1017,10 +1012,7 @@ static int __devexit m25p_remove(struct spi_device *spi) ...@@ -1017,10 +1012,7 @@ static int __devexit m25p_remove(struct spi_device *spi)
int status; int status;
/* Clean up MTD stuff. */ /* Clean up MTD stuff. */
if (mtd_has_partitions() && flash->partitioned) status = mtd_device_unregister(&flash->mtd);
status = del_mtd_partitions(&flash->mtd);
else
status = del_mtd_device(&flash->mtd);
if (status == 0) { if (status == 0) {
kfree(flash->command); kfree(flash->command);
kfree(flash); kfree(flash);
......
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