int bytes_read = nand_fileio_read(nand, &s);
if (bytes_read <= 0) {
command_print(CMD_CTX, "error while reading file");
- return nand_fileio_cleanup(&s);
+ nand_fileio_cleanup(&s);
+ return ERROR_FAIL;
}
s.size -= bytes_read;
command_print(CMD_CTX, "failed writing file %s "
"to NAND flash %s at offset 0x%8.8" PRIx32,
CMD_ARGV[1], CMD_ARGV[0], s.address);
- return nand_fileio_cleanup(&s);
+ nand_fileio_cleanup(&s);
+ return retval;
}
s.address += s.page_size;
}
"in %fs", first, last, p->bank_number, duration_elapsed(&bench));
}
- return ERROR_OK;
+ return retval;
}
COMMAND_HANDLER(handle_flash_protect_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);
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);
duration_start(&bench);
if (image_open(&image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK)
- return ERROR_OK;
+ return ERROR_FAIL;
image_size = 0x0;
retval = ERROR_OK;
command_print(CMD_CTX,
"error allocating buffer for section (%d bytes)",
(int)(image.sections[i].size));
+ retval = ERROR_FAIL;
break;
}