aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/tcl.c
diff options
context:
space:
mode:
authorHarishKumar <harishpresent@gmail.com>2014-12-09 19:38:08 +0530
committerFreddie Chopin <freddie.chopin@gmail.com>2016-11-04 21:21:15 +0000
commitb10037a0b784cab94e21b37c976ad2b5174d52ae (patch)
treeb7ed728eec23d463a83aeb8c9fc9bfdfa572a74a /src/flash/nor/tcl.c
parentd3445cd146f8efa6f5bdbd636f51e247ec7de766 (diff)
Tcl commands: Fix improper return status in flash commands and load_image.
Nand write command : nand_fileio_cleanup() always returns ERROR_OK. Due to this, handle_nand_write_command() retuns ERROR_OK in the case of nand failure. ERROR_FAIL should be returned. Flash erase_sector command : handle_flash_erase_command() always returns ERROR_OK even if the erase functionality of actual driver implementation fails. retval value should be returned. Flash write_bank command : handle_flash_write_bank_command() returns ERROR_OK even if fileio_open() and fileio_read fails. ERROR_FAIL should be returned. Load_image command : handle_load_image_command() retuns ERROR_OK even if image_open() fails. ERROR_FAIL should be returned. When the buffer is null, breaking the loop without setting retval = ERROR_FAIL would cause load_image to return ERROR_OK. Change-Id: Ice32f6036971ab5e8e4dd65edf54b394b001c80c Signed-off-by: HarishKumar <harishpresent@gmail.com> Reviewed-on: http://openocd.zylin.com/2431 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
Diffstat (limited to 'src/flash/nor/tcl.c')
-rw-r--r--src/flash/nor/tcl.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index d62fa746..69368229 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -341,7 +341,7 @@ COMMAND_HANDLER(handle_flash_erase_command)
"in %fs", first, last, p->bank_number, duration_elapsed(&bench));
}
- return ERROR_OK;
+ return retval;
}
COMMAND_HANDLER(handle_flash_protect_command)
@@ -600,7 +600,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], offset);
if (fileio_open(&fileio, CMD_ARGV[1], FILEIO_READ, FILEIO_BINARY) != ERROR_OK)
- return ERROR_OK;
+ return ERROR_FAIL;
size_t filesize;
retval = fileio_size(fileio, &filesize);
@@ -619,7 +619,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
if (fileio_read(fileio, filesize, buffer, &buf_cnt) != ERROR_OK) {
free(buffer);
fileio_close(fileio);
- return ERROR_OK;
+ return ERROR_FAIL;
}
retval = flash_driver_write(p, buffer, offset, buf_cnt);