fix error handling in flash fill

git-svn-id: svn://svn.berlios.de/openocd/trunk@1074 b42882b7-edfa-0310-969c-e2dbd0fdcd60
__archive__
oharboe 2008-10-16 13:37:59 +00:00
parent e2f941b546
commit 824c270142
1 changed files with 7 additions and 11 deletions

View File

@ -792,20 +792,16 @@ int handle_flash_fill_command(struct command_context_s *cmd_ctx, char *cmd, char
for (wrote=0; wrote<(count*wordsize); wrote+=sizeof(chunk)) for (wrote=0; wrote<(count*wordsize); wrote+=sizeof(chunk))
{ {
int cur_size = MIN( (count*wordsize - wrote) , 1024 ); int cur_size = MIN( (count*wordsize - wrote) , 1024 );
if (err == ERROR_OK)
{
flash_bank_t *bank; flash_bank_t *bank;
bank = get_flash_bank_by_addr(target, address); bank = get_flash_bank_by_addr(target, address);
if(bank == NULL) if(bank == NULL)
{ {
err = ERROR_FAIL; return ERROR_FAIL;
break;
} }
err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size); err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
wrote += cur_size;
}
if (err!=ERROR_OK) if (err!=ERROR_OK)
break; return err;
wrote += cur_size;
} }
if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK) if ((retval = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)