mtd: sst25l: convert to mtd_device_register()
authorJamie Iles <jamie@jamieiles.com>
Mon, 23 May 2011 09:22:59 +0000 (10:22 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 25 May 2011 01:21:33 +0000 (02:21 +0100)
Convert to mtd_device_register() and remove the check for
mtd_has_partitions() as we always have partitioning enabled now.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/devices/sst25l.c

index ac1d2442e101ef5cec7fe3f8adf10d67935d5501..1e2c430aaad241b112d4c33a3c90d1db1e3b3efe 100644 (file)
@@ -381,6 +381,8 @@ static int __devinit sst25l_probe(struct spi_device *spi)
        struct sst25l_flash *flash;
        struct flash_platform_data *data;
        int ret, i;
+       struct mtd_partition *parts = NULL;
+       int nr_parts = 0;
 
        flash_info = sst25l_match_device(spi);
        if (!flash_info)
@@ -420,46 +422,37 @@ static int __devinit sst25l_probe(struct spi_device *spi)
              flash->mtd.erasesize, flash->mtd.erasesize / 1024,
              flash->mtd.numeraseregions);
 
-       if (mtd_has_partitions()) {
-               struct mtd_partition *parts = NULL;
-               int nr_parts = 0;
 
-               if (mtd_has_cmdlinepart()) {
-                       static const char *part_probes[] =
-                               {"cmdlinepart", NULL};
+       if (mtd_has_cmdlinepart()) {
+               static const char *part_probes[] = {"cmdlinepart", NULL};
 
-                       nr_parts = parse_mtd_partitions(&flash->mtd,
-                                                       part_probes,
-                                                       &parts, 0);
-               }
+               nr_parts = parse_mtd_partitions(&flash->mtd,
+                                               part_probes,
+                                               &parts, 0);
+       }
 
-               if (nr_parts <= 0 && data && data->parts) {
-                       parts = data->parts;
-                       nr_parts = data->nr_parts;
-               }
+       if (nr_parts <= 0 && data && data->parts) {
+               parts = data->parts;
+               nr_parts = data->nr_parts;
+       }
 
-               if (nr_parts > 0) {
-                       for (i = 0; i < nr_parts; i++) {
-                               DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
-                                     "{.name = %s, .offset = 0x%llx, "
-                                     ".size = 0x%llx (%lldKiB) }\n",
-                                     i, parts[i].name,
-                                     (long long)parts[i].offset,
-                                     (long long)parts[i].size,
-                                     (long long)(parts[i].size >> 10));
-                       }
-
-                       flash->partitioned = 1;
-                       return add_mtd_partitions(&flash->mtd,
-                                                 parts, nr_parts);
+       if (nr_parts > 0) {
+               for (i = 0; i < nr_parts; i++) {
+                       DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
+                             "{.name = %s, .offset = 0x%llx, "
+                             ".size = 0x%llx (%lldKiB) }\n",
+                             i, parts[i].name,
+                             (long long)parts[i].offset,
+                             (long long)parts[i].size,
+                             (long long)(parts[i].size >> 10));
                }
 
-       } else if (data && data->nr_parts) {
-               dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
-                        data->nr_parts, data->name);
+               flash->partitioned = 1;
+               return mtd_device_register(&flash->mtd, parts,
+                                          nr_parts);
        }
 
-       ret = add_mtd_device(&flash->mtd);
+       ret = mtd_device_register(&flash->mtd, NULL, 0);
        if (ret == 1) {
                kfree(flash);
                dev_set_drvdata(&spi->dev, NULL);
@@ -474,10 +467,7 @@ static int __devexit sst25l_remove(struct spi_device *spi)
        struct sst25l_flash *flash = dev_get_drvdata(&spi->dev);
        int ret;
 
-       if (mtd_has_partitions() && flash->partitioned)
-               ret = del_mtd_partitions(&flash->mtd);
-       else
-               ret = del_mtd_device(&flash->mtd);
+       ret = mtd_device_unregister(&flash->mtd);
        if (ret == 0)
                kfree(flash);
        return ret;