Commit dba6fcf6 authored by Stefan Roese's avatar Stefan Roese Committed by Wolfgang Denk
Browse files

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: default avatarStefan Roese <sr@denx.de>
parent 7d6900eb
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment