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:
@@ -398,7 +398,7 @@ static const struct samd_part *samd_find_part(uint32_t id)
|
||||
|
||||
static int samd_protect_check(struct flash_bank *bank)
|
||||
{
|
||||
int res, prot_block;
|
||||
int res;
|
||||
uint16_t lock;
|
||||
|
||||
res = target_read_u16(bank->target,
|
||||
@@ -407,7 +407,7 @@ static int samd_protect_check(struct flash_bank *bank)
|
||||
return res;
|
||||
|
||||
/* Lock bits are active-low */
|
||||
for (prot_block = 0; prot_block < bank->num_prot_blocks; prot_block++)
|
||||
for (unsigned int prot_block = 0; prot_block < bank->num_prot_blocks; prot_block++)
|
||||
bank->prot_blocks[prot_block].is_protected = !(lock & (1u<<prot_block));
|
||||
|
||||
return ERROR_OK;
|
||||
@@ -725,10 +725,10 @@ static int samd_modify_user_row(struct target *target, uint64_t value,
|
||||
return samd_modify_user_row_masked(target, value << startb, mask);
|
||||
}
|
||||
|
||||
static int samd_protect(struct flash_bank *bank, int set, int first_prot_bl, int last_prot_bl)
|
||||
static int samd_protect(struct flash_bank *bank, int set,
|
||||
unsigned int first, unsigned int last)
|
||||
{
|
||||
int res = ERROR_OK;
|
||||
int prot_block;
|
||||
|
||||
/* We can issue lock/unlock region commands with the target running but
|
||||
* the settings won't persist unless we're able to modify the LOCK regions
|
||||
@@ -738,7 +738,7 @@ static int samd_protect(struct flash_bank *bank, int set, int first_prot_bl, int
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
for (prot_block = first_prot_bl; prot_block <= last_prot_bl; prot_block++) {
|
||||
for (unsigned int prot_block = first; prot_block <= last; prot_block++) {
|
||||
if (set != bank->prot_blocks[prot_block].is_protected) {
|
||||
/* Load an address that is within this protection block (we use offset 0) */
|
||||
res = target_write_u32(bank->target,
|
||||
@@ -763,7 +763,7 @@ static int samd_protect(struct flash_bank *bank, int set, int first_prot_bl, int
|
||||
|
||||
res = samd_modify_user_row(bank->target,
|
||||
set ? (uint64_t)0 : (uint64_t)UINT64_MAX,
|
||||
48 + first_prot_bl, 48 + last_prot_bl);
|
||||
48 + first, 48 + last);
|
||||
if (res != ERROR_OK)
|
||||
LOG_WARNING("SAMD: protect settings were not made persistent!");
|
||||
|
||||
@@ -775,9 +775,10 @@ exit:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int samd_erase(struct flash_bank *bank, int first_sect, int last_sect)
|
||||
static int samd_erase(struct flash_bank *bank, unsigned int first,
|
||||
unsigned int last)
|
||||
{
|
||||
int res, s;
|
||||
int res;
|
||||
struct samd_info *chip = (struct samd_info *)bank->driver_priv;
|
||||
|
||||
if (bank->target->state != TARGET_HALTED) {
|
||||
@@ -792,7 +793,7 @@ static int samd_erase(struct flash_bank *bank, int first_sect, int last_sect)
|
||||
}
|
||||
|
||||
/* For each sector to be erased */
|
||||
for (s = first_sect; s <= last_sect; s++) {
|
||||
for (unsigned int s = first; s <= last; s++) {
|
||||
res = samd_erase_row(bank->target, bank->sectors[s].offset);
|
||||
if (res != ERROR_OK) {
|
||||
LOG_ERROR("SAMD: failed to erase sector %d at 0x%08" PRIx32, s, bank->sectors[s].offset);
|
||||
|
||||
Reference in New Issue
Block a user