forked from auracaster/openocd
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:
@@ -1338,7 +1338,8 @@ static int kinetis_write_block(struct flash_bank *bank, const uint8_t *buffer,
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int kinetis_protect(struct flash_bank *bank, int set, int first, int last)
|
||||
static int kinetis_protect(struct flash_bank *bank, int set, unsigned int first,
|
||||
unsigned int last)
|
||||
{
|
||||
if (allow_fcf_writes) {
|
||||
LOG_ERROR("Protection setting is possible with 'kinetis fcf_source protection' only!");
|
||||
@@ -1350,7 +1351,7 @@ static int kinetis_protect(struct flash_bank *bank, int set, int first, int last
|
||||
return ERROR_FLASH_BANK_INVALID;
|
||||
}
|
||||
|
||||
for (int i = first; i < bank->num_prot_blocks && i <= last; i++)
|
||||
for (unsigned int i = first; i < bank->num_prot_blocks && i <= last; i++)
|
||||
bank->prot_blocks[i].is_protected = set;
|
||||
|
||||
LOG_INFO("Protection bits will be written at the next FCF sector erase or write.");
|
||||
@@ -1392,7 +1393,7 @@ static int kinetis_protect_check(struct flash_bank *bank)
|
||||
}
|
||||
|
||||
b = k_bank->protection_block;
|
||||
for (int i = 0; i < bank->num_prot_blocks; i++) {
|
||||
for (unsigned int i = 0; i < bank->num_prot_blocks; i++) {
|
||||
if ((fprot >> b) & 1)
|
||||
bank->prot_blocks[i].is_protected = 0;
|
||||
else
|
||||
@@ -1439,7 +1440,7 @@ static int kinetis_fill_fcf(struct flash_bank *bank, uint8_t *fcf)
|
||||
assert(bank_iter->prot_blocks);
|
||||
|
||||
if (k_bank->flash_class == FC_PFLASH) {
|
||||
for (int i = 0; i < bank_iter->num_prot_blocks; i++) {
|
||||
for (unsigned int i = 0; i < bank_iter->num_prot_blocks; i++) {
|
||||
if (bank_iter->prot_blocks[i].is_protected == 1)
|
||||
fprot &= ~pflash_bit;
|
||||
|
||||
@@ -1447,7 +1448,7 @@ static int kinetis_fill_fcf(struct flash_bank *bank, uint8_t *fcf)
|
||||
}
|
||||
|
||||
} else if (k_bank->flash_class == FC_FLEX_NVM) {
|
||||
for (int i = 0; i < bank_iter->num_prot_blocks; i++) {
|
||||
for (unsigned int i = 0; i < bank_iter->num_prot_blocks; i++) {
|
||||
if (bank_iter->prot_blocks[i].is_protected == 1)
|
||||
fdprot &= ~dflash_bit;
|
||||
|
||||
@@ -1616,7 +1617,8 @@ static void kinetis_invalidate_flash_cache(struct kinetis_chip *k_chip)
|
||||
}
|
||||
|
||||
|
||||
static int kinetis_erase(struct flash_bank *bank, int first, int last)
|
||||
static int kinetis_erase(struct flash_bank *bank, unsigned int first,
|
||||
unsigned int last)
|
||||
{
|
||||
int result;
|
||||
struct kinetis_flash_bank *k_bank = bank->driver_priv;
|
||||
@@ -1639,13 +1641,13 @@ static int kinetis_erase(struct flash_bank *bank, int first, int last)
|
||||
* requested erase is PFlash or NVM and encompasses the entire
|
||||
* block. Should be quicker.
|
||||
*/
|
||||
for (int i = first; i <= last; i++) {
|
||||
for (unsigned int i = first; i <= last; i++) {
|
||||
/* set command and sector address */
|
||||
result = kinetis_ftfx_command(bank->target, FTFx_CMD_SECTERASE, k_bank->prog_base + bank->sectors[i].offset,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, NULL);
|
||||
|
||||
if (result != ERROR_OK) {
|
||||
LOG_WARNING("erase sector %d failed", i);
|
||||
LOG_WARNING("erase sector %u failed", i);
|
||||
return ERROR_FLASH_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
@@ -2689,7 +2691,7 @@ static int kinetis_probe(struct flash_bank *bank)
|
||||
|
||||
if (bank->size > limit) {
|
||||
bank->size = limit;
|
||||
LOG_DEBUG("FlexNVM bank %d limited to 0x%08" PRIx32 " due to active EEPROM backup",
|
||||
LOG_DEBUG("FlexNVM bank %u limited to 0x%08" PRIx32 " due to active EEPROM backup",
|
||||
k_bank->bank_number, limit);
|
||||
}
|
||||
|
||||
@@ -2698,7 +2700,7 @@ static int kinetis_probe(struct flash_bank *bank)
|
||||
k_bank->bank_number, size_k, k_bank->prog_base, k_bank->sector_size);
|
||||
|
||||
} else {
|
||||
LOG_ERROR("Cannot determine parameters for bank %d, only %d banks on device",
|
||||
LOG_ERROR("Cannot determine parameters for bank %u, only %u banks on device",
|
||||
k_bank->bank_number, num_blocks);
|
||||
return ERROR_FLASH_BANK_INVALID;
|
||||
}
|
||||
@@ -2732,7 +2734,7 @@ static int kinetis_probe(struct flash_bank *bank)
|
||||
}
|
||||
|
||||
if (k_bank->sector_size == 0) {
|
||||
LOG_ERROR("Unknown sector size for bank %d", bank->bank_number);
|
||||
LOG_ERROR("Unknown sector size for bank %u", bank->bank_number);
|
||||
return ERROR_FLASH_BANK_INVALID;
|
||||
}
|
||||
|
||||
@@ -2827,7 +2829,7 @@ static int kinetis_blank_check(struct flash_bank *bank)
|
||||
|
||||
if (block_dirty) {
|
||||
/* the whole bank is not erased, check sector-by-sector */
|
||||
for (int i = 0; i < bank->num_sectors; i++) {
|
||||
for (unsigned int i = 0; i < bank->num_sectors; i++) {
|
||||
/* normal margin */
|
||||
result = kinetis_ftfx_command(bank->target, FTFx_CMD_SECTSTAT,
|
||||
k_bank->prog_base + bank->sectors[i].offset,
|
||||
@@ -2843,7 +2845,7 @@ static int kinetis_blank_check(struct flash_bank *bank)
|
||||
}
|
||||
} else {
|
||||
/* the whole bank is erased, update all sectors */
|
||||
for (int i = 0; i < bank->num_sectors; i++)
|
||||
for (unsigned int i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user