
From: chao zeng chao.zeng@siemens.com
When operating the write-protection flash,spi_flash_std_write() and spi_flash_std_erase() would return wrong result.The flash is protected, but write or erase the flash would show "OK".
Check the flash write protection state before operating the flash and give a prompt to show it has been locked if the write-protection has enbale
Signed-off-by: chao zeng chao.zeng@siemens.com
---
Changes for V2: - Return 0 not ENOPROTOOPT to refelect the flash feature - Output prompt information Changes for V3: - Modify output information - Delete return statement --- drivers/mtd/spi/sf_probe.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index f461082e03..f9e879aec5 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -109,6 +109,9 @@ static int spi_flash_std_write(struct udevice *dev, u32 offset, size_t len, struct mtd_info *mtd = &flash->mtd; size_t retlen;
+ if (flash->flash_is_locked && flash->flash_is_locked(flash, offset, len)) + printf("SF: Operate on the protected area.Writes will be ignored\n"); + return mtd->_write(mtd, offset, len, &retlen, buf); }
@@ -127,6 +130,9 @@ static int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len) instr.addr = offset; instr.len = len;
+ if (flash->flash_is_locked && flash->flash_is_locked(flash, offset, len)) + printf("SF: Operate on the protected area.Erase will be ignored\n"); + return mtd->_erase(mtd, &instr); }