aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/fm4.c
diff options
context:
space:
mode:
authorMarc Schink <dev@zapb.de>2020-06-07 17:00:13 +0200
committerTomas Vanek <vanekt@fbl.cz>2020-07-07 05:23:54 +0100
commitef14384b681af4f731f768bb866457832af6925f (patch)
treea8cb953d765484d4cd627eaa7ea71d9be6699866 /src/flash/nor/fm4.c
parenta2e6982a1816a0229bd5644156f3025a0e8cb6ce (diff)
downloadriscv-openocd-ef14384b681af4f731f768bb866457832af6925f.zip
riscv-openocd-ef14384b681af4f731f768bb866457832af6925f.tar.gz
riscv-openocd-ef14384b681af4f731f768bb866457832af6925f.tar.bz2
flash/nor: Use proper data types in driver API
Use 'unsigned int' and 'bool' instead of 'int' where appropriate. While at it, fix some coding style issues. No new Clang analyzer warnings. Change-Id: I700802c9ee81c3c7ae73108f0f8f06b15a4345f8 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/4929 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src/flash/nor/fm4.c')
-rw-r--r--src/flash/nor/fm4.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/flash/nor/fm4.c b/src/flash/nor/fm4.c
index 7e3a1c5..4daec78 100644
--- a/src/flash/nor/fm4.c
+++ b/src/flash/nor/fm4.c
@@ -98,14 +98,15 @@ static int fm4_enter_flash_cpu_rom_mode(struct target *target)
return ERROR_OK;
}
-static int fm4_flash_erase(struct flash_bank *bank, int first, int last)
+static int fm4_flash_erase(struct flash_bank *bank, unsigned int first,
+ unsigned int last)
{
struct target *target = bank->target;
struct working_area *workarea;
struct reg_param reg_params[4];
struct armv7m_algorithm armv7m_algo;
unsigned i;
- int retval, sector;
+ int retval;
const uint8_t erase_sector_code[] = {
#include "../../../contrib/loaders/flash/fm4/erase.inc"
};
@@ -115,7 +116,7 @@ static int fm4_flash_erase(struct flash_bank *bank, int first, int last)
return ERROR_TARGET_NOT_HALTED;
}
- LOG_DEBUG("Spansion FM4 erase sectors %d to %d", first, last);
+ LOG_DEBUG("Spansion FM4 erase sectors %u to %u", first, last);
retval = fm4_disable_hw_watchdog(target);
if (retval != ERROR_OK)
@@ -145,7 +146,7 @@ static int fm4_flash_erase(struct flash_bank *bank, int first, int last)
init_reg_param(&reg_params[2], "r2", 32, PARAM_OUT);
init_reg_param(&reg_params[3], "r3", 32, PARAM_IN);
- for (sector = first; sector <= last; sector++) {
+ for (unsigned int sector = first; sector <= last; sector++) {
uint32_t addr = bank->base + bank->sectors[sector].offset;
uint32_t result;
@@ -347,7 +348,6 @@ static int mb9bf_probe(struct flash_bank *bank)
{
struct fm4_flash_bank *fm4_bank = bank->driver_priv;
uint32_t flash_addr = bank->base;
- int i;
switch (fm4_bank->variant) {
case mb9bfx64:
@@ -369,10 +369,10 @@ static int mb9bf_probe(struct flash_bank *bank)
return ERROR_FLASH_OPER_UNSUPPORTED;
}
- LOG_DEBUG("%d sectors", bank->num_sectors);
+ LOG_DEBUG("%u sectors", bank->num_sectors);
bank->sectors = calloc(bank->num_sectors,
sizeof(struct flash_sector));
- for (i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
if (i < 4)
bank->sectors[i].size = 8 * 1024;
else if (i == 4)
@@ -409,7 +409,8 @@ static int s6e2cc_probe(struct flash_bank *bank)
struct fm4_flash_bank *fm4_bank = bank->driver_priv;
uint32_t u32_value;
uint32_t flash_addr = bank->base;
- int i, retval, num_sectors, num_extra_sectors;
+ int retval;
+ unsigned int i, num_extra_sectors, num_sectors;
retval = target_read_u32(target, DFCTRLR, &u32_value);
if (retval != ERROR_OK)
@@ -435,7 +436,7 @@ static int s6e2cc_probe(struct flash_bank *bank)
num_extra_sectors = (fm4_bank->macro_nr == 0) ? 1 : 4;
bank->num_sectors = num_sectors + num_extra_sectors;
- LOG_DEBUG("%d sectors", bank->num_sectors);
+ LOG_DEBUG("%u sectors", bank->num_sectors);
bank->sectors = calloc(bank->num_sectors,
sizeof(struct flash_sector));
for (i = 0; i < num_sectors; i++) {
@@ -466,12 +467,11 @@ static int s6e2cc_probe(struct flash_bank *bank)
static int s6e2dh_probe(struct flash_bank *bank)
{
uint32_t flash_addr = bank->base;
- int i;
bank->num_sectors = 10;
bank->sectors = calloc(bank->num_sectors,
sizeof(struct flash_sector));
- for (i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
if (i < 4)
bank->sectors[i].size = 8 * 1024;
else if (i == 4)