Skip to content

Commit 55274b6

Browse files
Stephen.Zhangkelvincheung
authored andcommitted
fix issue for flash erase param length aligning with sector size.
Signed-off-by: Stephen.Zhang <Stephen.Zhang@unisoc.com>
1 parent 81e552f commit 55274b6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/src/sfc/hal_sfc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,15 @@ __ramfunc int spiflash_write(struct spi_flash *flash, u32_t offset,
10521052
__ramfunc int spiflash_erase(struct spi_flash *flash, u32_t offset, u32_t len)
10531053
{
10541054
u32_t i, sectors_nr;
1055+
u32_t dummp;
10551056

1056-
sectors_nr = len / flash->sector_size;
1057+
dummp = len % flash->sector_size;
1058+
if (dummp) {
1059+
LOG_ERR("SF: Erase param length not multiple of erase size\n");
1060+
return -1;
1061+
}
10571062

1063+
sectors_nr = len / flash->sector_size;
10581064
for (i = 0; i < sectors_nr; i++) {
10591065
if (spiflash_cmd_erase(flash, CMD_SECTOR_ERASE, offset))
10601066
return -1;

0 commit comments

Comments
 (0)