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>
This commit is contained in:
Marc Schink
2020-06-07 17:00:13 +02:00
committed by Tomas Vanek
parent a2e6982a18
commit ef14384b68
70 changed files with 773 additions and 755 deletions

View File

@@ -330,7 +330,8 @@ static int niietcm4_uflash_page_erase(struct flash_bank *bank, int page_num, int
/**
* Enable or disable protection of userflash pages
*/
static int niietcm4_uflash_protect(struct flash_bank *bank, int mem_type, int set, int first, int last)
static int niietcm4_uflash_protect(struct flash_bank *bank, int mem_type,
int set, unsigned int first, unsigned int last)
{
int retval;
if (mem_type == INFO_MEM_TYPE) {
@@ -359,7 +360,7 @@ static int niietcm4_uflash_protect(struct flash_bank *bank, int mem_type, int se
if (retval != ERROR_OK)
return retval;
/* modify dump */
for (int i = first; i <= last; i++) {
for (unsigned int i = first; i <= last; i++) {
uint32_t reg_num = i/8;
uint32_t bit_num = i%8;
if (set)
@@ -563,7 +564,7 @@ COMMAND_HANDLER(niietcm4_handle_uflash_erase_command)
return retval;
}
command_print(CMD, "Erase %s userflash pages %d through %d done!", CMD_ARGV[0], first, last);
command_print(CMD, "Erase %s userflash pages %u through %u done!", CMD_ARGV[0], first, last);
return retval;
}
@@ -693,11 +694,11 @@ COMMAND_HANDLER(niietcm4_handle_uflash_protect_command)
int set;
if (strcmp("on", CMD_ARGV[3]) == 0) {
command_print(CMD, "Try to enable %s userflash sectors %d through %d protection. Please wait ... ",
command_print(CMD, "Try to enable %s userflash sectors %u through %u protection. Please wait ... ",
CMD_ARGV[0], first, last);
set = 1;
} else if (strcmp("off", CMD_ARGV[3]) == 0) {
command_print(CMD, "Try to disable %s userflash sectors %d through %d protection. Please wait ... ",
command_print(CMD, "Try to disable %s userflash sectors %u through %u protection. Please wait ... ",
CMD_ARGV[0], first, last);
set = 0;
} else
@@ -1111,7 +1112,7 @@ static int niietcm4_protect_check(struct flash_bank *bank)
} else {
uflash_addr = BF_LOCK_ADDR;
uflash_cmd = UFMC_MAGIC_KEY | UFMC_READ_IFB;
for (int i = 0; i < bank->num_sectors/8; i++) {
for (unsigned int i = 0; i < bank->num_sectors/8; i++) {
retval = target_write_u32(target, UFMA, uflash_addr);
if (retval != ERROR_OK)
return retval;
@@ -1163,7 +1164,8 @@ static int niietcm4_mass_erase(struct flash_bank *bank)
return retval;
}
static int niietcm4_erase(struct flash_bank *bank, int first, int last)
static int niietcm4_erase(struct flash_bank *bank, unsigned int first,
unsigned int last)
{
struct target *target = bank->target;
struct niietcm4_flash_bank *niietcm4_info = bank->driver_priv;
@@ -1188,7 +1190,7 @@ static int niietcm4_erase(struct flash_bank *bank, int first, int last)
/* erasing pages */
unsigned int page_size = bank->size / bank->num_sectors;
for (int i = first; i <= last; i++) {
for (unsigned int i = first; i <= last; i++) {
/* current page addr */
flash_addr = i*page_size;
retval = target_write_u32(target, FMA, flash_addr);
@@ -1211,7 +1213,8 @@ static int niietcm4_erase(struct flash_bank *bank, int first, int last)
return retval;
}
static int niietcm4_protect(struct flash_bank *bank, int set, int first, int last)
static int niietcm4_protect(struct flash_bank *bank, int set,
unsigned int first, unsigned int last)
{
struct target *target = bank->target;
struct niietcm4_flash_bank *niietcm4_info = bank->driver_priv;
@@ -1251,7 +1254,7 @@ static int niietcm4_protect(struct flash_bank *bank, int set, int first, int las
if (retval != ERROR_OK)
return retval;
/* modify dump */
for (int i = first; i <= last; i++) {
for (unsigned int i = first; i <= last; i++) {
uint32_t reg_num = i/8;
uint32_t bit_num = i%8;
if (set)