summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2009-05-11 15:54:13 +0200
committerWolfgang Denk <wd@denx.de>2009-06-03 23:45:27 +0200
commitdba6fcf6517faa5dda7df8109febe03c9c72a6f5 (patch)
treeaa163dfef6b498091bf0eba490fd791cdbcc995a /drivers/mtd
parent7d6900ebe16d679c0e03f8d1584b64057a64ce39 (diff)
downloadu-boot-imx-dba6fcf6517faa5dda7df8109febe03c9c72a6f5.zip
u-boot-imx-dba6fcf6517faa5dda7df8109febe03c9c72a6f5.tar.gz
u-boot-imx-dba6fcf6517faa5dda7df8109febe03c9c72a6f5.tar.bz2
cfi_mtd: Fix bug in last sector detection
This patch now enabled this cfi-mtd wrapper to correctly detect and erase the last sector in an NOR FLASH device. Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/cfi_mtd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c
index f03e4fb..4a76917 100644
--- a/drivers/mtd/cfi_mtd.c
+++ b/drivers/mtd/cfi_mtd.c
@@ -43,11 +43,16 @@ static int cfi_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
int s_last = -1;
int error, sect;
- for (sect = 0; sect < fi->sector_count - 1; sect++) {
+ for (sect = 0; sect < fi->sector_count; sect++) {
if (a_start == fi->start[sect])
s_first = sect;
- if (a_end == fi->start[sect + 1]) {
+ if (sect < fi->sector_count - 1) {
+ if (a_end == fi->start[sect + 1]) {
+ s_last = sect;
+ break;
+ }
+ } else {
s_last = sect;
break;
}