summaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
Diffstat (limited to 'src/target')
-rw-r--r--src/target/armv7m.c4
-rw-r--r--src/target/avrt.c4
-rw-r--r--src/target/mips32_pracc.c30
-rw-r--r--src/target/mips_ejtag.c6
-rw-r--r--src/target/xscale.c4
5 files changed, 24 insertions, 24 deletions
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index 9d89086e..fc3f47cc 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -596,7 +596,7 @@ int armv7m_checksum_memory(struct target *target,
}
/* 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;
@@ -659,7 +659,7 @@ int armv7m_blank_check_memory(struct target *target,
}
/* 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;
diff --git a/src/target/avrt.c b/src/target/avrt.c
index dc527f5e..6ba62068 100644
--- a/src/target/avrt.c
+++ b/src/target/avrt.c
@@ -196,7 +196,7 @@ int mcu_write_ir(struct jtag_tap *tap, uint8_t *ir_in, uint8_t *ir_out, int ir_l
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;
@@ -217,7 +217,7 @@ int mcu_write_dr(struct jtag_tap *tap, uint8_t *dr_in, uint8_t *dr_out, int dr_l
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;
diff --git a/src/target/mips32_pracc.c b/src/target/mips32_pracc.c
index 4f9a7042..604d34ed 100644
--- a/src/target/mips32_pracc.c
+++ b/src/target/mips32_pracc.c
@@ -348,8 +348,8 @@ int mips32_pracc_read_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int co
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;
}
@@ -387,8 +387,8 @@ int mips32_pracc_read_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_t
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;
}
@@ -459,8 +459,8 @@ int mips32_pracc_read_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int co
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;
@@ -540,8 +540,8 @@ int mips32_pracc_read_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int cou
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;
@@ -619,7 +619,7 @@ int mips32_pracc_write_mem32(struct mips_ejtag *ejtag_info, uint32_t addr, int c
memcpy(&param_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);
@@ -654,8 +654,8 @@ int mips32_pracc_write_u32(struct mips_ejtag *ejtag_info, uint32_t addr, uint32_
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;
}
@@ -714,7 +714,7 @@ int mips32_pracc_write_mem16(struct mips_ejtag *ejtag_info, uint32_t addr, int c
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);
@@ -777,7 +777,7 @@ int mips32_pracc_write_mem8(struct mips_ejtag *ejtag_info, uint32_t addr, int co
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);
@@ -851,7 +851,7 @@ int mips32_pracc_write_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
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;
@@ -928,7 +928,7 @@ int mips32_pracc_read_regs(struct mips_ejtag *ejtag_info, uint32_t *regs)
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;
diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c
index 6f06d9a3..68a39faf 100644
--- a/src/target/mips_ejtag.c
+++ b/src/target/mips_ejtag.c
@@ -143,7 +143,7 @@ int mips_ejtag_step_enable(struct mips_ejtag *ejtag_info)
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;
@@ -169,7 +169,7 @@ int mips_ejtag_step_disable(struct mips_ejtag *ejtag_info)
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;
@@ -234,7 +234,7 @@ int mips_ejtag_read_debug(struct mips_ejtag *ejtag_info, uint32_t* debug_reg)
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;
diff --git a/src/target/xscale.c b/src/target/xscale.c
index e402a11c..07fcc4c0 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -412,7 +412,7 @@ static int xscale_read_tx(struct target *target, int consume)
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));
@@ -2825,7 +2825,7 @@ static void xscale_build_reg_cache(struct target *target)
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);