Commit 98b3979b authored by Jamie Iles's avatar Jamie Iles Committed by David Woodhouse

mtd: sst25l: convert to mtd_device_register()

Convert to mtd_device_register() and remove the check for
mtd_has_partitions() as we always have partitioning enabled now.
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 436c06da
...@@ -381,6 +381,8 @@ static int __devinit sst25l_probe(struct spi_device *spi) ...@@ -381,6 +381,8 @@ static int __devinit sst25l_probe(struct spi_device *spi)
struct sst25l_flash *flash; struct sst25l_flash *flash;
struct flash_platform_data *data; struct flash_platform_data *data;
int ret, i; int ret, i;
struct mtd_partition *parts = NULL;
int nr_parts = 0;
flash_info = sst25l_match_device(spi); flash_info = sst25l_match_device(spi);
if (!flash_info) if (!flash_info)
...@@ -420,46 +422,37 @@ static int __devinit sst25l_probe(struct spi_device *spi) ...@@ -420,46 +422,37 @@ static int __devinit sst25l_probe(struct spi_device *spi)
flash->mtd.erasesize, flash->mtd.erasesize / 1024, flash->mtd.erasesize, flash->mtd.erasesize / 1024,
flash->mtd.numeraseregions); flash->mtd.numeraseregions);
if (mtd_has_partitions()) {
struct mtd_partition *parts = NULL;
int nr_parts = 0;
if (mtd_has_cmdlinepart()) { if (mtd_has_cmdlinepart()) {
static const char *part_probes[] = static const char *part_probes[] = {"cmdlinepart", NULL};
{"cmdlinepart", NULL};
nr_parts = parse_mtd_partitions(&flash->mtd, nr_parts = parse_mtd_partitions(&flash->mtd,
part_probes, part_probes,
&parts, 0); &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;
} }
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", return mtd_device_register(&flash->mtd, parts,
data->nr_parts, data->name); nr_parts);
} }
ret = add_mtd_device(&flash->mtd); ret = mtd_device_register(&flash->mtd, NULL, 0);
if (ret == 1) { if (ret == 1) {
kfree(flash); kfree(flash);
dev_set_drvdata(&spi->dev, NULL); dev_set_drvdata(&spi->dev, NULL);
...@@ -474,10 +467,7 @@ static int __devexit sst25l_remove(struct spi_device *spi) ...@@ -474,10 +467,7 @@ static int __devexit sst25l_remove(struct spi_device *spi)
struct sst25l_flash *flash = dev_get_drvdata(&spi->dev); struct sst25l_flash *flash = dev_get_drvdata(&spi->dev);
int ret; int ret;
if (mtd_has_partitions() && flash->partitioned) ret = mtd_device_unregister(&flash->mtd);
ret = del_mtd_partitions(&flash->mtd);
else
ret = del_mtd_device(&flash->mtd);
if (ret == 0) if (ret == 0)
kfree(flash); kfree(flash);
return ret; return ret;
......
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