diff mbox series

Do not skip sectors to erase if unlock is not supported

Message ID 1513601474-17574-1-git-send-email-sbabic@denx.de
State Accepted
Headers show
Series Do not skip sectors to erase if unlock is not supported | expand

Commit Message

Stefano Babic Dec. 18, 2017, 12:51 p.m. UTC
Not all flashes support lock, and mtd_is_locked() return true
even if unlock is unsupported, and the sector is not erased.
This generates an error later when sector is written.

Check the error code and ignore it if the feature is unsupported
for the MTD device to be erased.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/mtd-interface.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/corelib/mtd-interface.c b/corelib/mtd-interface.c
index ee7d62a..93c7215 100644
--- a/corelib/mtd-interface.c
+++ b/corelib/mtd-interface.c
@@ -98,8 +98,10 @@  int flash_erase(int mtdnum)
 		/* Unlock memory if required */
 		if (mtd_is_locked(mtd, fd, eb)) {
 			if (mtd_unlock(mtd, fd, eb) != 0) {
-				TRACE("%s: MTD unlock failure", mtd_device);
-				continue;
+				if (errno != EOPNOTSUPP) {
+					TRACE("%s: MTD unlock failure", mtd_device);
+					continue;
+				}
 			}
 		}