When we pass the size parameter to the command "sf erase",
flash_is_unlocked() api is getting updated with length which is
incorrect. Fix this flash_is_unlocked() api by passing the size
parameter.

ZynqMP> sf erase 0 100000
len=0x8000000 which is flash size
size=0x100000

We need to update the size in the flash_is_unlocked() api and not
the length.

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbar...@amd.com>
---
 cmd/sf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/sf.c b/cmd/sf.c
index 55bef2f769..977ffcb63c 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -366,7 +366,7 @@ static int do_spi_flash_erase(int argc, char *const argv[])
        }
 
        if (flash->flash_is_unlocked &&
-           !flash->flash_is_unlocked(flash, offset, len)) {
+           !flash->flash_is_unlocked(flash, offset, size)) {
                printf("ERROR: flash area is locked\n");
                return CMD_RET_FAILURE;
        }
-- 
2.17.1

Reply via email to