Commit 436c06da authored by Jamie Iles's avatar Jamie Iles Committed by David Woodhouse

mtd: dataflash: 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 ba52f3a2
...@@ -637,6 +637,8 @@ add_dataflash_otp(struct spi_device *spi, char *name, ...@@ -637,6 +637,8 @@ add_dataflash_otp(struct spi_device *spi, char *name,
struct flash_platform_data *pdata = spi->dev.platform_data; struct flash_platform_data *pdata = spi->dev.platform_data;
char *otp_tag = ""; char *otp_tag = "";
int err = 0; int err = 0;
struct mtd_partition *parts;
int nr_parts = 0;
priv = kzalloc(sizeof *priv, GFP_KERNEL); priv = kzalloc(sizeof *priv, GFP_KERNEL);
if (!priv) if (!priv)
...@@ -675,33 +677,25 @@ add_dataflash_otp(struct spi_device *spi, char *name, ...@@ -675,33 +677,25 @@ add_dataflash_otp(struct spi_device *spi, char *name,
pagesize, otp_tag); pagesize, otp_tag);
dev_set_drvdata(&spi->dev, priv); dev_set_drvdata(&spi->dev, priv);
if (mtd_has_partitions()) { if (mtd_has_cmdlinepart()) {
struct mtd_partition *parts; static const char *part_probes[] = { "cmdlinepart", NULL, };
int nr_parts = 0;
if (mtd_has_cmdlinepart()) { nr_parts = parse_mtd_partitions(device, part_probes, &parts,
static const char *part_probes[] 0);
= { "cmdlinepart", NULL, }; }
nr_parts = parse_mtd_partitions(device,
part_probes, &parts, 0);
}
if (nr_parts <= 0 && pdata && pdata->parts) { if (nr_parts <= 0 && pdata && pdata->parts) {
parts = pdata->parts; parts = pdata->parts;
nr_parts = pdata->nr_parts; nr_parts = pdata->nr_parts;
} }
if (nr_parts > 0) { if (nr_parts > 0) {
priv->partitioned = 1; priv->partitioned = 1;
err = add_mtd_partitions(device, parts, nr_parts); err = mtd_device_register(device, parts, nr_parts);
goto out; goto out;
} }
} else if (pdata && pdata->nr_parts)
dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
pdata->nr_parts, device->name);
if (add_mtd_device(device) == 1) if (mtd_device_register(device, NULL, 0) == 1)
err = -ENODEV; err = -ENODEV;
out: out:
...@@ -939,10 +933,7 @@ static int __devexit dataflash_remove(struct spi_device *spi) ...@@ -939,10 +933,7 @@ static int __devexit dataflash_remove(struct spi_device *spi)
DEBUG(MTD_DEBUG_LEVEL1, "%s: remove\n", dev_name(&spi->dev)); DEBUG(MTD_DEBUG_LEVEL1, "%s: remove\n", dev_name(&spi->dev));
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) {
dev_set_drvdata(&spi->dev, NULL); dev_set_drvdata(&spi->dev, NULL);
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