From: Stefan Roese Date: Mon, 11 May 2009 13:54:13 +0000 (+0200) Subject: cfi_mtd: Fix bug in last sector detection X-Git-Tag: v2009.06-rc3~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dba6fcf6517faa5dda7df8109febe03c9c72a6f5;p=platform%2Fkernel%2Fu-boot.git 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 --- 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; }