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

@@ -3171,12 +3171,11 @@ static int sam3_GetDetails(struct sam3_bank_private *pPrivate)
static int _sam3_probe(struct flash_bank *bank, int noise)
{
unsigned x;
int r;
struct sam3_bank_private *pPrivate;
LOG_DEBUG("Begin: Bank: %d, Noise: %d", bank->bank_number, noise);
LOG_DEBUG("Begin: Bank: %u, Noise: %d", bank->bank_number, noise);
if (bank->target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
@@ -3201,7 +3200,7 @@ static int _sam3_probe(struct flash_bank *bank, int noise)
return r;
/* update the flash bank size */
for (x = 0; x < SAM3_MAX_FLASH_BANKS; x++) {
for (unsigned int x = 0; x < SAM3_MAX_FLASH_BANKS; x++) {
if (bank->base == pPrivate->pChip->details.bank[x].base_address) {
bank->size = pPrivate->pChip->details.bank[x].size_bytes;
break;
@@ -3216,7 +3215,7 @@ static int _sam3_probe(struct flash_bank *bank, int noise)
}
bank->num_sectors = pPrivate->nsectors;
for (x = 0; ((int)(x)) < bank->num_sectors; x++) {
for (unsigned int x = 0; x < bank->num_sectors; x++) {
bank->sectors[x].size = pPrivate->sector_size;
bank->sectors[x].offset = x * (pPrivate->sector_size);
/* mark as unknown */
@@ -3252,7 +3251,8 @@ static int sam3_auto_probe(struct flash_bank *bank)
return _sam3_probe(bank, 0);
}
static int sam3_erase(struct flash_bank *bank, int first, int last)
static int sam3_erase(struct flash_bank *bank, unsigned int first,
unsigned int last)
{
struct sam3_bank_private *pPrivate;
int r;
@@ -3273,7 +3273,7 @@ static int sam3_erase(struct flash_bank *bank, int first, int last)
if (!(pPrivate->probed))
return ERROR_FLASH_BANK_NOT_PROBED;
if ((first == 0) && ((last + 1) == ((int)(pPrivate->nsectors)))) {
if ((first == 0) && ((last + 1) == pPrivate->nsectors)) {
/* whole chip */
LOG_DEBUG("Here");
return FLASHD_EraseEntireBank(pPrivate);
@@ -3282,7 +3282,8 @@ static int sam3_erase(struct flash_bank *bank, int first, int last)
return ERROR_OK;
}
static int sam3_protect(struct flash_bank *bank, int set, int first, int last)
static int sam3_protect(struct flash_bank *bank, int set, unsigned int first,
unsigned int last)
{
struct sam3_bank_private *pPrivate;
int r;
@@ -3298,9 +3299,9 @@ static int sam3_protect(struct flash_bank *bank, int set, int first, int last)
return ERROR_FLASH_BANK_NOT_PROBED;
if (set)
r = FLASHD_Lock(pPrivate, (unsigned)(first), (unsigned)(last));
r = FLASHD_Lock(pPrivate, first, last);
else
r = FLASHD_Unlock(pPrivate, (unsigned)(first), (unsigned)(last));
r = FLASHD_Unlock(pPrivate, first, last);
LOG_DEBUG("End: r=%d", r);
return r;