#endif
#include "imp.h"
+#include <helper/binarybuffer.h>
#include <helper/bits.h>
#include <helper/time_support.h>
#include <target/algorithm.h>
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], io_base);
stmqspi_info = malloc(sizeof(struct stmqspi_flash_bank));
- if (stmqspi_info == NULL) {
+ if (!stmqspi_info) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
retval = wait_till_ready(bank, SPI_MASS_ERASE_TIMEOUT);
duration_measure(&bench);
- if (retval == ERROR_OK) {
- /* set all sectors as erased */
- for (sector = 0; sector < bank->num_sectors; sector++)
- bank->sectors[sector].is_erased = 1;
-
+ if (retval == ERROR_OK)
command_print(CMD, "stmqspi mass erase completed in %fs (%0.3f KiB/s)",
duration_elapsed(&bench),
duration_kbps(&bench, bank->size));
- } else {
+ else
command_print(CMD, "stmqspi mass erase not completed even after %fs",
duration_elapsed(&bench));
- }
err:
/* Switch to memory mapped mode before return to prompt */
bank->num_sectors =
stmqspi_info->dev.size_in_bytes / stmqspi_info->dev.sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
/* create and fill sectors array */
bank->num_sectors = stmqspi_info->dev.size_in_bytes / stmqspi_info->dev.sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
retval = ERROR_FAIL;
goto err;