From 02e2798b3188c87910e6843a827af9fb3d578ee5 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Thu, 4 Feb 2021 23:11:06 -0500 Subject: [PATCH] cmd: sf: Display errno on erase failure If there is an error while erasing SPI flash, no errno is displayed. This makes it difficult to determine the cause of the error. This change mirrors the logic for write errors above. Signed-off-by: Sean Anderson Reviewed-by: Bin Meng Reviewed-by: Pratyush Yadav Reviewed-by: Jagan Teki --- cmd/sf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/sf.c b/cmd/sf.c index c0d6a8f8a0..de80fcd38b 100644 --- a/cmd/sf.c +++ b/cmd/sf.c @@ -344,8 +344,11 @@ static int do_spi_flash_erase(int argc, char *const argv[]) } ret = spi_flash_erase(flash, offset, size); - printf("SF: %zu bytes @ %#x Erased: %s\n", (size_t)size, (u32)offset, - ret ? "ERROR" : "OK"); + printf("SF: %zu bytes @ %#x Erased: ", (size_t)size, (u32)offset); + if (ret) + printf("ERROR %d\n", ret); + else + printf("OK\n"); return ret == 0 ? 0 : 1; } -- 2.39.5