@@ -28,7 +28,7 @@ static char mtd_ubi_blacklist[100] = { 0 };
*/
#define EMPTY_BYTE 0xFF
-int flash_erase(int mtdnum)
+int flash_erase_sector(int mtdnum, off_t start, size_t size)
{
int fd;
char mtd_device[80];
@@ -62,8 +62,8 @@ int flash_erase(int mtdnum)
return -ENOMEM;
}
- eb_start = 0;
- eb_cnt = (mtd->size / mtd->eb_size) - eb_start;
+ eb_start = start;
+ eb_cnt = ((size ? size : mtd->size) / mtd->eb_size) - eb_start;
for (eb = 0; eb < eb_start + eb_cnt; eb++) {
/* Always skip bad sectors */
@@ -134,6 +134,10 @@ erase_out:
return ret;
}
+int flash_erase(int mtdnum)
+{
+ return flash_erase_sector(mtdnum, 0, 0);
+}
void mtd_init(void)
{
@@ -52,6 +52,7 @@ void mtd_cleanup (void);
int get_mtd_from_device(char *s);
int get_mtd_from_name(const char *s);
int flash_erase(int mtdnum);
+int flash_erase_sector(int mtdnum, off_t start, size_t size);
struct flash_description *get_flash_info(void);
#define isNand(flash, index) \
This is used to erase just a part of the flash and reuse the code of flash_erase. Signed-off-by: Stefano Babic <sbabic@denx.de> --- corelib/mtd-interface.c | 10 +++++++--- include/flash.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-)