diff mbox

[U-Boot,01/11] spi: sf: Print the error code on failure

Message ID 1433688642-19861-2-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass June 7, 2015, 2:50 p.m. UTC
Rather than just 'ERROR', display the error code, which may be useful, at
least with driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/cmd_sf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Bin Meng June 8, 2015, 1:27 a.m. UTC | #1
On Sun, Jun 7, 2015 at 10:50 PM, Simon Glass <sjg@chromium.org> wrote:
> Rather than just 'ERROR', display the error code, which may be useful, at
> least with driver model.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/cmd_sf.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index 342021d..668df69 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -300,8 +300,12 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
>                 else
>                         ret = spi_flash_write(flash, offset, len, buf);
>
> -               printf("SF: %zu bytes @ %#x %s: %s\n", (size_t)len, (u32)offset,
> -                      read ? "Read" : "Written", ret ? "ERROR" : "OK");
> +               printf("SF: %zu bytes @ %#x %s: ", (size_t)len, (u32)offset,
> +                      read ? "Read" : "Written");
> +               if (ret)
> +                       printf("ERROR %d\n", ret);
> +               else
> +                       printf("OK\n");
>         }
>
>         unmap_physmem(buf, len);
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Marek Vasut June 8, 2015, 8:25 a.m. UTC | #2
On Sunday, June 07, 2015 at 04:50:32 PM, Simon Glass wrote:
> Rather than just 'ERROR', display the error code, which may be useful, at
> least with driver model.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut
Jagan Teki June 8, 2015, 5:49 p.m. UTC | #3
On 8 June 2015 at 13:55, Marek Vasut <marex@denx.de> wrote:
> On Sunday, June 07, 2015 at 04:50:32 PM, Simon Glass wrote:
>> Rather than just 'ERROR', display the error code, which may be useful, at
>> least with driver model.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Acked-by: Marek Vasut <marex@denx.de>

Reviewed-by: Jagan Teki <jteki@openedev.com>

thanks!
Simon Glass June 12, 2015, 11:02 p.m. UTC | #4
On 8 June 2015 at 11:49, Jagan Teki <jteki@openedev.com> wrote:
> On 8 June 2015 at 13:55, Marek Vasut <marex@denx.de> wrote:
>> On Sunday, June 07, 2015 at 04:50:32 PM, Simon Glass wrote:
>>> Rather than just 'ERROR', display the error code, which may be useful, at
>>> least with driver model.
>>>
>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>>
>> Acked-by: Marek Vasut <marex@denx.de>
>
> Reviewed-by: Jagan Teki <jteki@openedev.com>

Since this is part of a bug-fix series I'll apply it now.

Applied to u-boot-x86.
diff mbox

Patch

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 342021d..668df69 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -300,8 +300,12 @@  static int do_spi_flash_read_write(int argc, char * const argv[])
 		else
 			ret = spi_flash_write(flash, offset, len, buf);
 
-		printf("SF: %zu bytes @ %#x %s: %s\n", (size_t)len, (u32)offset,
-		       read ? "Read" : "Written", ret ? "ERROR" : "OK");
+		printf("SF: %zu bytes @ %#x %s: ", (size_t)len, (u32)offset,
+		       read ? "Read" : "Written");
+		if (ret)
+			printf("ERROR %d\n", ret);
+		else
+			printf("OK\n");
 	}
 
 	unmap_physmem(buf, len);