struct jtagspi_flash_bank {
struct jtag_tap *tap;
const struct flash_device *dev;
- int probed;
+ bool probed;
uint32_t ir;
};
return ERROR_COMMAND_SYNTAX_ERROR;
info = malloc(sizeof(struct jtagspi_flash_bank));
- if (info == NULL) {
+ if (!info) {
LOG_ERROR("no memory for flash bank info");
return ERROR_FAIL;
}
bank->driver_priv = info;
info->tap = NULL;
- info->probed = 0;
+ info->probed = false;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], info->ir);
return ERROR_OK;
lenb = DIV_ROUND_UP(len, 8);
data_buf = malloc(lenb);
if (lenb > 0) {
- if (data_buf == NULL) {
+ if (!data_buf) {
LOG_ERROR("no memory for spi buffer");
return ERROR_FAIL;
}
if (info->probed)
free(bank->sectors);
- info->probed = 0;
+ info->probed = false;
- if (bank->target->tap == NULL) {
+ if (!bank->target->tap) {
LOG_ERROR("Target has no JTAG tap");
return ERROR_FAIL;
}
/* create and fill sectors array */
bank->num_sectors = info->dev->size_in_bytes / sectorsize;
sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- if (sectors == NULL) {
+ if (!sectors) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
}
bank->sectors = sectors;
- info->probed = 1;
+ info->probed = true;
return ERROR_OK;
}
return ERROR_OK;
}
-static int jtagspi_info(struct flash_bank *bank, char *buf, int buf_size)
+static int jtagspi_info(struct flash_bank *bank, struct command_invocation *cmd)
{
struct jtagspi_flash_bank *info = bank->driver_priv;
if (!(info->probed)) {
- snprintf(buf, buf_size, "\nJTAGSPI flash bank not probed yet\n");
+ command_print_sameline(cmd, "\nJTAGSPI flash bank not probed yet\n");
return ERROR_OK;
}
- snprintf(buf, buf_size, "\nSPIFI flash information:\n"
+ command_print_sameline(cmd, "\nSPIFI flash information:\n"
" Device \'%s\' (ID 0x%08" PRIx32 ")\n",
info->dev->name, info->dev->device_id);