From c69553cbc51770f61cf3b9225d46d058fa2544d0 Mon Sep 17 00:00:00 2001 From: Øyvind Harboe Date: Mon, 3 Jan 2011 13:30:28 +0100 Subject: error handling: the error number is not part of the user interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not propagate error number to user. This is for internal programming purposes only. Error messages to the user is reported as text via LOG_ERROR(). Signed-off-by: Øyvind Harboe --- src/flash/nor/core.c | 18 +++++++++--------- src/flash/nor/pic32mx.c | 4 ++-- src/flash/nor/str7x.c | 4 ---- src/flash/nor/str9x.c | 2 +- src/flash/nor/tcl.c | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) (limited to 'src/flash') diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index ff467d3d..2c3b2f82 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -46,7 +46,7 @@ int flash_driver_erase(struct flash_bank *bank, int first, int last) retval = bank->driver->erase(bank, first, last); if (retval != ERROR_OK) { - LOG_ERROR("failed erasing sectors %d to %d (%d)", first, last, retval); + LOG_ERROR("failed erasing sectors %d to %d", first, last); } return retval; @@ -80,7 +80,7 @@ int flash_driver_protect(struct flash_bank *bank, int set, int first, int last) retval = bank->driver->protect(bank, set, first, last); if (retval != ERROR_OK) { - LOG_ERROR("failed setting protection for areas %d to %d (%d)", first, last, retval); + LOG_ERROR("failed setting protection for areas %d to %d", first, last); } return retval; @@ -94,8 +94,8 @@ int flash_driver_write(struct flash_bank *bank, retval = bank->driver->write(bank, buffer, offset, count); if (retval != ERROR_OK) { - LOG_ERROR("error writing to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32 " (%d)", - bank->base, offset, retval); + LOG_ERROR("error writing to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32, + bank->base, offset); } return retval; @@ -111,8 +111,8 @@ int flash_driver_read(struct flash_bank *bank, retval = bank->driver->read(bank, buffer, offset, count); if (retval != ERROR_OK) { - LOG_ERROR("error reading to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32 " (%d)", - bank->base, offset, retval); + LOG_ERROR("error reading to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32, + bank->base, offset); } return retval; @@ -209,7 +209,7 @@ int get_flash_bank_by_name(const char *name, struct flash_bank **bank_result) if (retval != ERROR_OK) { - LOG_ERROR("auto_probe failed %d\n", retval); + LOG_ERROR("auto_probe failed\n"); return retval; } } @@ -232,7 +232,7 @@ int get_flash_bank_by_num(int num, struct flash_bank **bank) if (retval != ERROR_OK) { - LOG_ERROR("auto_probe failed %d\n", retval); + LOG_ERROR("auto_probe failed\n"); return retval; } *bank = p; @@ -253,7 +253,7 @@ int get_flash_bank_by_addr(struct target *target, uint32_t addr, bool check, str if (retval != ERROR_OK) { - LOG_ERROR("auto_probe failed %d\n", retval); + LOG_ERROR("auto_probe failed\n"); return retval; } /* check whether address belongs to this flash bank */ diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c index 6a277021..89fe9b05 100644 --- a/src/flash/nor/pic32mx.c +++ b/src/flash/nor/pic32mx.c @@ -513,8 +513,8 @@ static int pic32mx_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs } else if (retval == ERROR_FLASH_OPERATION_FAILED) { - LOG_ERROR("flash writing failed with error code: 0x%x", retval); - return ERROR_FLASH_OPERATION_FAILED; + LOG_ERROR("flash writing failed"); + return retval; } } else diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c index 6136f310..b872bc3c 100644 --- a/src/flash/nor/str7x.c +++ b/src/flash/nor/str7x.c @@ -325,10 +325,6 @@ static int str7x_result(struct flash_bank *bank) err = ERROR_FAIL; } } - if (err != ERROR_OK) - { - LOG_ERROR("FLASH_ER register contents: 0x%" PRIx32, retval); - } return retval; } diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c index 8f8e83c8..303daa04 100644 --- a/src/flash/nor/str9x.c +++ b/src/flash/nor/str9x.c @@ -562,7 +562,7 @@ static int str9x_write(struct flash_bank *bank, } else if (retval == ERROR_FLASH_OPERATION_FAILED) { - LOG_ERROR("flash writing failed with error code: 0x%x", retval); + LOG_ERROR("flash writing failed"); return ERROR_FLASH_OPERATION_FAILED; } } diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index fe1f85d9..4c64a28d 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -106,7 +106,7 @@ COMMAND_HANDLER(handle_flash_info_command) retval = p->driver->info(p, buf, sizeof(buf)); command_print(CMD_CTX, "%s", buf); if (retval != ERROR_OK) - LOG_ERROR("error retrieving flash info (%d)", retval); + LOG_ERROR("error retrieving flash info"); } return ERROR_OK; -- cgit v1.2.3