LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F);
}
- for (i = 0; i < (int)(sizeof(avft_chips_info) / sizeof(avft_chips_info[0])); i++)
+ for (i = 0; i < (int)ARRAY_SIZE(avft_chips_info); i++)
{
if (avft_chips_info[i].chip_id == EXTRACT_PART(device_id))
{
LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F);
}
- for (i = 0; i < (int)(sizeof(avft_chips_info) / sizeof(avft_chips_info[0])); i++)
+ for (i = 0; i < (int)ARRAY_SIZE(avft_chips_info); i++)
{
if (avft_chips_info[i].chip_id == EXTRACT_PART(device_id))
{
};
#define TMS470R1A256_NUM_SECTORS \
- (sizeof(TMS470R1A256_SECTORS)/sizeof(TMS470R1A256_SECTORS[0]))
+ ARRAY_SIZE(TMS470R1A256_SECTORS)
const struct flash_sector TMS470R1A288_BANK0_SECTORS[] = {
{0x00000000, 0x00002000, -1, -1},
};
#define TMS470R1A288_BANK0_NUM_SECTORS \
- (sizeof(TMS470R1A288_BANK0_SECTORS)/sizeof(TMS470R1A288_BANK0_SECTORS[0]))
+ ARRAY_SIZE(TMS470R1A288_BANK0_SECTORS)
const struct flash_sector TMS470R1A288_BANK1_SECTORS[] = {
{0x00040000, 0x00010000, -1, -1},
};
#define TMS470R1A288_BANK1_NUM_SECTORS \
- (sizeof(TMS470R1A288_BANK1_SECTORS)/sizeof(TMS470R1A288_BANK1_SECTORS[0]))
+ ARRAY_SIZE(TMS470R1A288_BANK1_SECTORS)
const struct flash_sector TMS470R1A384_BANK0_SECTORS[] = {
{0x00000000, 0x00002000, -1, -1},
};
#define TMS470R1A384_BANK0_NUM_SECTORS \
- (sizeof(TMS470R1A384_BANK0_SECTORS)/sizeof(TMS470R1A384_BANK0_SECTORS[0]))
+ ARRAY_SIZE(TMS470R1A384_BANK0_SECTORS)
const struct flash_sector TMS470R1A384_BANK1_SECTORS[] = {
{0x00020000, 0x00008000, -1, -1},
};
#define TMS470R1A384_BANK1_NUM_SECTORS \
- (sizeof(TMS470R1A384_BANK1_SECTORS)/sizeof(TMS470R1A384_BANK1_SECTORS[0]))
+ ARRAY_SIZE(TMS470R1A384_BANK1_SECTORS)
const struct flash_sector TMS470R1A384_BANK2_SECTORS[] = {
{0x00040000, 0x00008000, -1, -1},
};
#define TMS470R1A384_BANK2_NUM_SECTORS \
- (sizeof(TMS470R1A384_BANK2_SECTORS)/sizeof(TMS470R1A384_BANK2_SECTORS[0]))
+ ARRAY_SIZE(TMS470R1A384_BANK2_SECTORS)
/* ---------------------------------------------------------------------- */
{
static const char* type_str[] =
{"BM", "AM", "100AX", "UNKNOWN", "2232C", "232R", "2232H", "4232H"};
- unsigned no_of_known_types = sizeof(type_str) / sizeof(type_str[0]) - 1;
+ unsigned no_of_known_types = ARRAY_SIZE(type_str) - 1;
unsigned type_index = ((unsigned)ftdi_device <= no_of_known_types)
? ftdi_device : FT_DEVICE_UNKNOWN;
LOG_INFO("device: %lu \"%s\"", ftdi_device, type_str[type_index]);
ftdi_device = ftdic.type;
static const char* type_str[] =
{"AM", "BM", "2232C", "R", "2232H", "4232H", "Unknown"};
- unsigned no_of_known_types = sizeof(type_str) / sizeof(type_str[0]) - 1;
+ unsigned no_of_known_types = ARRAY_SIZE(type_str) - 1;
unsigned type_index = ((unsigned)ftdi_device < no_of_known_types)
? ftdi_device : no_of_known_types;
LOG_DEBUG("FTDI chip type: %i \"%s\"", (int)ftdi_device, type_str[type_index]);
dtc_2, sizeof(dtc_2), (ST7_FOSC * 2) / (1000 * 2), 2
}};
-const size_t rlink_speed_table_size = sizeof(rlink_speed_table) / sizeof(*rlink_speed_table);
+const size_t rlink_speed_table_size = ARRAY_SIZE(rlink_speed_table);
{
tap_state_t states[8];
- if ((argc < 2) || ((size_t)argc > (sizeof(states)/sizeof(*states) + 1)))
+ if ((argc < 2) || ((size_t)argc > (ARRAY_SIZE(states) + 1)))
{
Jim_WrongNumArgs(interp, 1, args, "wrong arguments");
return JIM_ERR;
}
/* convert flash writing code into a buffer in target endianness */
- for (i = 0; i < (sizeof(cortex_m3_crc_code)/sizeof(uint16_t)); i++)
+ for (i = 0; i < ARRAY_SIZE(cortex_m3_crc_code); i++)
if ((retval = target_write_u16(target, crc_algorithm->address + i*sizeof(uint16_t), cortex_m3_crc_code[i])) != ERROR_OK)
{
return retval;
}
/* convert flash writing code into a buffer in target endianness */
- for (i = 0; i < (sizeof(erase_check_code)/sizeof(uint16_t)); i++)
+ for (i = 0; i < ARRAY_SIZE(erase_check_code); i++)
target_write_u16(target, erase_check_algorithm->address + i*sizeof(uint16_t), erase_check_code[i]);
armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
field[0].num_bits = tap->ir_length;
field[0].out_value = ir_out;
field[0].in_value = ir_in;
- jtag_add_plain_ir_scan(sizeof(field) / sizeof(field[0]), field, jtag_set_end_state(TAP_IDLE));
+ jtag_add_plain_ir_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE));
}
return ERROR_OK;
field[0].num_bits = dr_len;
field[0].out_value = dr_out;
field[0].in_value = dr_in;
- jtag_add_plain_dr_scan(sizeof(field) / sizeof(field[0]), field, jtag_set_end_state(TAP_IDLE));
+ jtag_add_plain_dr_scan(ARRAY_SIZE(field), field, jtag_set_end_state(TAP_IDLE));
}
return ERROR_OK;
param_in[0] = addr;
param_in[1] = blocksize;
- if ((retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code,
- sizeof(param_in)/sizeof(param_in[0]), param_in, blocksize, &buf[bytesread], 1)) != ERROR_OK)
+ if ((retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code,
+ ARRAY_SIZE(param_in), param_in, blocksize, &buf[bytesread], 1)) != ERROR_OK)
{
return retval;
}
param_in[0] = addr;
- if ((retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code,
- sizeof(param_in)/sizeof(param_in[0]), param_in, sizeof(uint32_t), buf, 1)) != ERROR_OK)
+ if ((retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code,
+ ARRAY_SIZE(param_in), param_in, sizeof(uint32_t), buf, 1)) != ERROR_OK)
{
return retval;
}
param_in[0] = addr;
param_in[1] = blocksize;
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]), param_in, count, param_out, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ ARRAY_SIZE(param_in), param_in, count, param_out, 1);
// count -= blocksize;
// addr += blocksize;
param_in[0] = addr;
param_in[1] = blocksize;
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]), param_in, count, param_out, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ ARRAY_SIZE(param_in), param_in, count, param_out, 1);
// count -= blocksize;
// addr += blocksize;
memcpy(¶m_in[2], buf, count * sizeof(uint32_t));
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
count + 2, param_in, 0, NULL, 1);
free(param_in);
param_in[0] = addr;
param_in[1] = *buf;
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
- sizeof(param_in)/sizeof(param_in[0]),param_in, 0, NULL, 1);
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
+ ARRAY_SIZE(param_in),param_in, 0, NULL, 1);
return ERROR_OK;
}
param_in[i + 2] = buf[i];
}
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
count + 2, param_in, 0, NULL, 1);
free(param_in);
param_in[i + 2] = buf[i];
}
- retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
count +2, param_in, 0, NULL, 1);
free(param_in);
int retval;
- retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
38, regs, 0, NULL, 1);
return retval;
int retval;
- retval = mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ retval = mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
0, NULL, 38, regs, 1);
return retval;
MIPS32_NOP,
};
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
0, NULL, 0, NULL, 1);
return ERROR_OK;
MIPS32_NOP,
};
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
0, NULL, 0, NULL, 1);
return ERROR_OK;
MIPS32_NOP,
};
- mips32_pracc_exec(ejtag_info, sizeof(code)/sizeof(code[0]), code, \
+ mips32_pracc_exec(ejtag_info, ARRAY_SIZE(code), code, \
0, NULL, 1, debug_reg, 1);
return ERROR_OK;
jtag_add_pathmove(3, path);
else
{
- jtag_add_pathmove(sizeof(noconsume_path)/sizeof(*noconsume_path), noconsume_path);
+ jtag_add_pathmove(ARRAY_SIZE(noconsume_path), noconsume_path);
}
jtag_add_dr_scan(3, fields, jtag_set_end_state(TAP_IDLE));
struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
struct xscale_reg *arch_info = malloc(sizeof(xscale_reg_arch_info));
int i;
- int num_regs = sizeof(xscale_reg_arch_info) / sizeof(struct xscale_reg);
+ int num_regs = ARRAY_SIZE(xscale_reg_arch_info);
(*cache_p) = armv4_5_build_reg_cache(target, armv4_5);