9
0
Fork 0

m25p80: prevent endless loop in erase

"erase /dev/myflash0 0+1" erased the whole flash,
similar for other value of count if you guessed the
erae block size wrong.

Signed-off-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Johannes Stezenbach 2012-06-06 18:04:56 +02:00 committed by Sascha Hauer
parent 497d1c49f4
commit 011702664f
1 changed files with 2 additions and 0 deletions

View File

@ -235,6 +235,8 @@ static ssize_t m25p80_erase(struct cdev *cdev, size_t count, unsigned long offse
if (erase_sector(flash, addr))
return -EIO;
if (len <= flash->erasesize)
break;
addr += flash->erasesize;
len -= flash->erasesize;
show_progress(progress++);