aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2011-06-02 09:59:16 -0400
committerArtem Bityutskiy <artem.bityutskiy@intel.com>2011-09-11 08:02:12 -0400
commit871770b5c857aa39e87785726ce3ec5a41cd387a (patch)
treee5916a4ee2ab86110fdea86c3c3f4bc30052ac37 /drivers/mtd
parentf44dcbd06236ecc610bd03abeceac77a21cb019e (diff)
mtd: m25p80.c: use mtd_device_parse_register
Replace custom invocations of parse_mtd_partitions and mtd_device_register with common mtd_device_parse_register call. This would bring: standard handling of all errors, fallback to default partitions, etc. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/m25p80.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 399c2349265..66a3555f07d 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -88,7 +88,6 @@ struct m25p {
88 struct spi_device *spi; 88 struct spi_device *spi;
89 struct mutex lock; 89 struct mutex lock;
90 struct mtd_info mtd; 90 struct mtd_info mtd;
91 unsigned partitioned:1;
92 u16 page_size; 91 u16 page_size;
93 u16 addr_width; 92 u16 addr_width;
94 u8 erase_opcode; 93 u8 erase_opcode;
@@ -825,8 +824,6 @@ static int __devinit m25p_probe(struct spi_device *spi)
825 struct m25p *flash; 824 struct m25p *flash;
826 struct flash_info *info; 825 struct flash_info *info;
827 unsigned i; 826 unsigned i;
828 struct mtd_partition *parts = NULL;
829 int nr_parts = 0;
830 struct mtd_part_parser_data ppdata; 827 struct mtd_part_parser_data ppdata;
831 828
832 /* Platform data helps sort out which chip type we have, as 829 /* Platform data helps sort out which chip type we have, as
@@ -970,28 +967,9 @@ static int __devinit m25p_probe(struct spi_device *spi)
970 /* partitions should match sector boundaries; and it may be good to 967 /* partitions should match sector boundaries; and it may be good to
971 * use readonly partitions for writeprotected sectors (BP2..BP0). 968 * use readonly partitions for writeprotected sectors (BP2..BP0).
972 */ 969 */
973 nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, &ppdata); 970 return mtd_device_parse_register(&flash->mtd, NULL, &ppdata,
974 971 data ? data->parts : NULL,
975 if (nr_parts <= 0 && data && data->parts) { 972 data ? data->nr_parts : 0);
976 parts = data->parts;
977 nr_parts = data->nr_parts;
978 }
979
980 if (nr_parts > 0) {
981 for (i = 0; i < nr_parts; i++) {
982 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
983 "{.name = %s, .offset = 0x%llx, "
984 ".size = 0x%llx (%lldKiB) }\n",
985 i, parts[i].name,
986 (long long)parts[i].offset,
987 (long long)parts[i].size,
988 (long long)(parts[i].size >> 10));
989 }
990 flash->partitioned = 1;
991 }
992
993 return mtd_device_register(&flash->mtd, parts, nr_parts) == 1 ?
994 -ENODEV : 0;
995} 973}
996 974
997 975