aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/str7x.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/str7x.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/str7x.c')
-rw-r--r--src/flash/nor/str7x.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c
index eaef197..dd72f53 100644
--- a/src/flash/nor/str7x.c
+++ b/src/flash/nor/str7x.c
@@ -138,7 +138,7 @@ static int str7x_build_block_list(struct flash_bank *bank)
struct str7x_flash_bank *str7x_info = bank->driver_priv;
int i;
- int num_sectors;
+ unsigned int num_sectors;
int b0_sectors = 0, b1_sectors = 0;
switch (bank->size) {
@@ -306,7 +306,6 @@ static int str7x_protect_check(struct flash_bank *bank)
struct str7x_flash_bank *str7x_info = bank->driver_priv;
struct target *target = bank->target;
- int i;
uint32_t flash_flags;
if (bank->target->state != TARGET_HALTED) {
@@ -319,7 +318,7 @@ static int str7x_protect_check(struct flash_bank *bank)
if (retval != ERROR_OK)
return retval;
- for (i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
if (flash_flags & str7x_info->sector_bits[i])
bank->sectors[i].is_protected = 0;
else
@@ -329,12 +328,12 @@ static int str7x_protect_check(struct flash_bank *bank)
return ERROR_OK;
}
-static int str7x_erase(struct flash_bank *bank, int first, int last)
+static int str7x_erase(struct flash_bank *bank, unsigned int first,
+ unsigned int last)
{
struct str7x_flash_bank *str7x_info = bank->driver_priv;
struct target *target = bank->target;
- int i;
uint32_t cmd;
uint32_t sectors = 0;
int err;
@@ -344,7 +343,7 @@ static int str7x_erase(struct flash_bank *bank, int first, int last)
return ERROR_TARGET_NOT_HALTED;
}
- for (i = first; i <= last; i++)
+ for (unsigned int i = first; i <= last; i++)
sectors |= str7x_info->sector_bits[i];
LOG_DEBUG("sectors: 0x%" PRIx32 "", sectors);
@@ -377,17 +376,17 @@ static int str7x_erase(struct flash_bank *bank, int first, int last)
if (err != ERROR_OK)
return err;
- for (i = first; i <= last; i++)
+ for (unsigned int i = first; i <= last; i++)
bank->sectors[i].is_erased = 1;
return ERROR_OK;
}
-static int str7x_protect(struct flash_bank *bank, int set, int first, int last)
+static int str7x_protect(struct flash_bank *bank, int set, unsigned int first,
+ unsigned int last)
{
struct str7x_flash_bank *str7x_info = bank->driver_priv;
struct target *target = bank->target;
- int i;
uint32_t cmd;
uint32_t protect_blocks;
@@ -399,7 +398,7 @@ static int str7x_protect(struct flash_bank *bank, int set, int first, int last)
protect_blocks = 0xFFFFFFFF;
if (set) {
- for (i = first; i <= last; i++)
+ for (unsigned int i = first; i <= last; i++)
protect_blocks &= ~(str7x_info->sector_bits[i]);
}
@@ -568,7 +567,6 @@ static int str7x_write(struct flash_bank *bank, const uint8_t *buffer,
uint32_t cmd;
int retval;
uint32_t check_address = offset;
- int i;
if (bank->target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
@@ -580,7 +578,7 @@ static int str7x_write(struct flash_bank *bank, const uint8_t *buffer,
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
- for (i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
uint32_t sec_start = bank->sectors[i].offset;
uint32_t sec_end = sec_start + bank->sectors[i].size;