aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/m25p80.c
diff options
context:
space:
mode:
authorJamie Iles <jamie@jamieiles.com>2011-05-23 05:22:57 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-05-24 21:21:24 -0400
commitba52f3a253d12848fa0e9c242a3406963ae98ece (patch)
tree14437f0e2b800d64ce4689fadb25baffe3ff3124 /drivers/mtd/devices/m25p80.c
parent711a632d1f0d3ffc576f7a298f66888f66014d61 (diff)
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: Jamie Iles <jamie@jamieiles.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/devices/m25p80.c')
-rw-r--r--drivers/mtd/devices/m25p80.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 2b0d0542d9df..35180e475c4c 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -825,6 +825,8 @@ static int __devinit m25p_probe(struct spi_device *spi)
825 struct m25p *flash; 825 struct m25p *flash;
826 struct flash_info *info; 826 struct flash_info *info;
827 unsigned i; 827 unsigned i;
828 struct mtd_partition *parts = NULL;
829 int nr_parts = 0;
828 830
829 /* Platform data helps sort out which chip type we have, as 831 /* Platform data helps sort out which chip type we have, as
830 * well as how this board partitions it. If we don't have 832 * 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 /* partitions should match sector boundaries; and it may be good to 968 /* partitions should match sector boundaries; and it may be good to
967 * use readonly partitions for writeprotected sectors (BP2..BP0). 969 * use readonly partitions for writeprotected sectors (BP2..BP0).
968 */ 970 */
969 if (mtd_has_partitions()) { 971 if (mtd_has_cmdlinepart()) {
970 struct mtd_partition *parts = NULL; 972 static const char *part_probes[]
971 int nr_parts = 0; 973 = { "cmdlinepart", NULL, };
972 974
973 if (mtd_has_cmdlinepart()) { 975 nr_parts = parse_mtd_partitions(&flash->mtd,
974 static const char *part_probes[] 976 part_probes, &parts, 0);
975 = { "cmdlinepart", NULL, }; 977 }
976
977 nr_parts = parse_mtd_partitions(&flash->mtd,
978 part_probes, &parts, 0);
979 }
980 978
981 if (nr_parts <= 0 && data && data->parts) { 979 if (nr_parts <= 0 && data && data->parts) {
982 parts = data->parts; 980 parts = data->parts;
983 nr_parts = data->nr_parts; 981 nr_parts = data->nr_parts;
984 } 982 }
985 983
986#ifdef CONFIG_MTD_OF_PARTS 984#ifdef CONFIG_MTD_OF_PARTS
987 if (nr_parts <= 0 && spi->dev.of_node) { 985 if (nr_parts <= 0 && spi->dev.of_node) {
988 nr_parts = of_mtd_parse_partitions(&spi->dev, 986 nr_parts = of_mtd_parse_partitions(&spi->dev,
989 spi->dev.of_node, &parts); 987 spi->dev.of_node, &parts);
990 } 988 }
991#endif 989#endif
992 990
993 if (nr_parts > 0) { 991 if (nr_parts > 0) {
994 for (i = 0; i < nr_parts; i++) { 992 for (i = 0; i < nr_parts; i++) {
995 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " 993 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
996 "{.name = %s, .offset = 0x%llx, " 994 "{.name = %s, .offset = 0x%llx, "
997 ".size = 0x%llx (%lldKiB) }\n", 995 ".size = 0x%llx (%lldKiB) }\n",
998 i, parts[i].name, 996 i, parts[i].name,
999 (long long)parts[i].offset, 997 (long long)parts[i].offset,
1000 (long long)parts[i].size, 998 (long long)parts[i].size,
1001 (long long)(parts[i].size >> 10)); 999 (long long)(parts[i].size >> 10));
1002 }
1003 flash->partitioned = 1;
1004 return add_mtd_partitions(&flash->mtd, parts, nr_parts);
1005 } 1000 }
1006 } else if (data && data->nr_parts) 1001 flash->partitioned = 1;
1007 dev_warn(&spi->dev, "ignoring %d default partitions on %s\n", 1002 }
1008 data->nr_parts, data->name);
1009 1003
1010 return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0; 1004 return mtd_device_register(&flash->mtd, parts, nr_parts) == 1 ?
1005 -ENODEV : 0;
1011} 1006}
1012 1007
1013 1008
@@ -1017,10 +1012,7 @@ static int __devexit m25p_remove(struct spi_device *spi)
1017 int status; 1012 int status;
1018 1013
1019 /* Clean up MTD stuff. */ 1014 /* Clean up MTD stuff. */
1020 if (mtd_has_partitions() && flash->partitioned) 1015 status = mtd_device_unregister(&flash->mtd);
1021 status = del_mtd_partitions(&flash->mtd);
1022 else
1023 status = del_mtd_device(&flash->mtd);
1024 if (status == 0) { 1016 if (status == 0) {
1025 kfree(flash->command); 1017 kfree(flash->command);
1026 kfree(flash); 1018 kfree(flash);