diff mbox series

[01/14] cmd: sf: Display errno on erase failure

Message ID 20210201003436.1180667-2-seanga2@gmail.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series spi: dw: Add support for DUAL/QUAD/OCTAL modes | expand

Commit Message

Sean Anderson Feb. 1, 2021, 12:34 a.m. UTC
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 <seanga2@gmail.com>
---

 cmd/sf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Bin Meng Feb. 1, 2021, 5:06 a.m. UTC | #1
On Mon, Feb 1, 2021 at 8:35 AM Sean Anderson <seanga2@gmail.com> wrote:
>
> 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 <seanga2@gmail.com>
> ---
>
>  cmd/sf.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Pratyush Yadav Feb. 1, 2021, 12:51 p.m. UTC | #2
On 31/01/21 07:34PM, Sean Anderson wrote:
> 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 <seanga2@gmail.com>

Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
diff mbox series

Patch

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;
 }