summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2009-03-18 11:17:37 +0100
committerStefan Roese <sr@denx.de>2009-04-29 11:06:06 +0200
commitf8e2b3107ee00f2782f8ebf47e3f09cda4e2353a (patch)
treed3a0679e1dfc290fcb87485e1a25e0614d5fa887
parent4d9eab89b3b2c2ed432b14d355a56f274d8aac75 (diff)
downloadu-boot-imx-f8e2b3107ee00f2782f8ebf47e3f09cda4e2353a.zip
u-boot-imx-f8e2b3107ee00f2782f8ebf47e3f09cda4e2353a.tar.gz
u-boot-imx-f8e2b3107ee00f2782f8ebf47e3f09cda4e2353a.tar.bz2
MTD: Change cfi-mtd to accept non-uniform sector sizes
With this patch non-uniform NOR FLASH chips (chips with multiple erase regions) can be exported via the cfi-mtd layer and therefor used by UBI. We select the largest sector size as erasesize. The cfi driver will make sure that the smaller sectors are handled correctly. Signed-off-by: Stefan Roese <sr@denx.de>
-rw-r--r--drivers/mtd/cfi_mtd.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c
index 9ac1c86..f03e4fb 100644
--- a/drivers/mtd/cfi_mtd.c
+++ b/drivers/mtd/cfi_mtd.c
@@ -142,22 +142,12 @@ static int cfi_mtd_set_erasesize(struct mtd_info *mtd, flash_info_t *fi)
int sect_size = 0;
int sect;
+ /*
+ * Select the largest sector size as erasesize (e.g. for UBI)
+ */
for (sect = 0; sect < fi->sector_count; sect++) {
- if (!sect_size) {
+ if (flash_sector_size(fi, sect) > sect_size)
sect_size = flash_sector_size(fi, sect);
- continue;
- }
-
- if (sect_size != flash_sector_size(fi, sect)) {
- sect_size = 0;
- break;
- }
- }
-
- if (!sect_size) {
- puts("cfi-mtd: devices with multiple sector sizes are"
- "not supported\n");
- return -EINVAL;
}
mtd->erasesize = sect_size;