summaryrefslogtreecommitdiff
path: root/src/flash
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-19 10:03:35 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-19 10:03:35 +0000
commit4e0bad8679a7d88b6185de73c34f88fd95bd017e (patch)
treecbeda938d02834b74407791ba553f880342168fa /src/flash
parent6e4680fc26bff1940e7109bb0d1a2bae1ef631c6 (diff)
downloadopenocd_libswd-4e0bad8679a7d88b6185de73c34f88fd95bd017e.tar.gz
openocd_libswd-4e0bad8679a7d88b6185de73c34f88fd95bd017e.tar.bz2
openocd_libswd-4e0bad8679a7d88b6185de73c34f88fd95bd017e.tar.xz
openocd_libswd-4e0bad8679a7d88b6185de73c34f88fd95bd017e.zip
fixed error handling in flash bank.
git-svn-id: svn://svn.berlios.de/openocd/trunk@933 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash')
-rw-r--r--src/flash/flash.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c
index 9178ff9c..e5adcc86 100644
--- a/src/flash/flash.c
+++ b/src/flash/flash.c
@@ -264,6 +264,7 @@ flash_bank_t *get_flash_bank_by_num(int num)
int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
+ int retval;
int i;
int found = 0;
target_t *target;
@@ -276,7 +277,7 @@ int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char
if ((target = get_target_by_num(strtoul(args[5], NULL, 0))) == NULL)
{
LOG_ERROR("target %lu not defined", strtoul(args[5], NULL, 0));
- return ERROR_OK;
+ return ERROR_FAIL;
}
for (i = 0; flash_drivers[i]; i++)
@@ -289,7 +290,7 @@ int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char
if (flash_drivers[i]->register_commands(cmd_ctx) != ERROR_OK)
{
LOG_ERROR("couldn't register '%s' commands", args[0]);
- exit(-1);
+ return ERROR_FAIL;
}
c = malloc(sizeof(flash_bank_t));
@@ -304,11 +305,11 @@ int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char
c->sectors = NULL;
c->next = NULL;
- if (flash_drivers[i]->flash_bank_command(cmd_ctx, cmd, args, argc, c) != ERROR_OK)
+ if ((retval=flash_drivers[i]->flash_bank_command(cmd_ctx, cmd, args, argc, c)) != ERROR_OK)
{
LOG_ERROR("'%s' driver rejected flash bank at 0x%8.8x", args[0], c->base);
free(c);
- return ERROR_OK;
+ return retval;
}
/* put flash bank in linked list */
@@ -332,7 +333,7 @@ int handle_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char
if (!found)
{
LOG_ERROR("flash driver '%s' not found", args[0]);
- exit(-1);
+ return ERROR_FAIL;
}
return ERROR_OK;