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:
@@ -427,7 +427,8 @@ static int ambiqmicro_mass_erase(struct flash_bank *bank)
|
||||
}
|
||||
|
||||
|
||||
static int ambiqmicro_erase(struct flash_bank *bank, int first, int last)
|
||||
static int ambiqmicro_erase(struct flash_bank *bank, unsigned int first,
|
||||
unsigned int last)
|
||||
{
|
||||
struct ambiqmicro_flash_bank *ambiqmicro_info = bank->driver_priv;
|
||||
struct target *target = bank->target;
|
||||
@@ -447,14 +448,14 @@ static int ambiqmicro_erase(struct flash_bank *bank, int first, int last)
|
||||
* Check pages.
|
||||
* Fix num_pages for the device.
|
||||
*/
|
||||
if ((first < 0) || (last < first) || (last >= (int)ambiqmicro_info->num_pages))
|
||||
if ((last < first) || (last >= ambiqmicro_info->num_pages))
|
||||
return ERROR_FLASH_SECTOR_INVALID;
|
||||
|
||||
/*
|
||||
* Just Mass Erase if all pages are given.
|
||||
* TODO: Fix num_pages for the device
|
||||
*/
|
||||
if ((first == 0) && (last == ((int)ambiqmicro_info->num_pages-1)))
|
||||
if ((first == 0) && (last == (ambiqmicro_info->num_pages - 1)))
|
||||
return ambiqmicro_mass_erase(bank);
|
||||
|
||||
/*
|
||||
@@ -502,7 +503,7 @@ static int ambiqmicro_erase(struct flash_bank *bank, int first, int last)
|
||||
/*
|
||||
* Erase the pages.
|
||||
*/
|
||||
LOG_INFO("Erasing pages %d to %d on bank %d", first, last, bank->bank_number);
|
||||
LOG_INFO("Erasing pages %u to %u on bank %u", first, last, bank->bank_number);
|
||||
|
||||
/*
|
||||
* passed pc, addr = ROM function, handle breakpoints, not debugging.
|
||||
@@ -512,7 +513,7 @@ static int ambiqmicro_erase(struct flash_bank *bank, int first, int last)
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
LOG_INFO("%d pages erased!", 1+(last-first));
|
||||
LOG_INFO("%u pages erased!", 1+(last-first));
|
||||
|
||||
if (first == 0) {
|
||||
/*
|
||||
@@ -527,7 +528,8 @@ static int ambiqmicro_erase(struct flash_bank *bank, int first, int last)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int ambiqmicro_protect(struct flash_bank *bank, int set, int first, int last)
|
||||
static int ambiqmicro_protect(struct flash_bank *bank, int set,
|
||||
unsigned int first, unsigned int last)
|
||||
{
|
||||
/* struct ambiqmicro_flash_bank *ambiqmicro_info = bank->driver_priv;
|
||||
* struct target *target = bank->target; */
|
||||
@@ -679,7 +681,7 @@ static int ambiqmicro_probe(struct flash_bank *bank)
|
||||
bank->size = ambiqmicro_info->pagesize * ambiqmicro_info->num_pages;
|
||||
bank->num_sectors = ambiqmicro_info->num_pages;
|
||||
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
|
||||
for (int i = 0; i < bank->num_sectors; i++) {
|
||||
for (unsigned int i = 0; i < bank->num_sectors; i++) {
|
||||
bank->sectors[i].offset = i * ambiqmicro_info->pagesize;
|
||||
bank->sectors[i].size = ambiqmicro_info->pagesize;
|
||||
bank->sectors[i].is_erased = -1;
|
||||
@@ -775,8 +777,6 @@ static int ambiqmicro_otp_program(struct flash_bank *bank,
|
||||
|
||||
COMMAND_HANDLER(ambiqmicro_handle_mass_erase_command)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (CMD_ARGC < 1)
|
||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||
|
||||
@@ -787,7 +787,7 @@ COMMAND_HANDLER(ambiqmicro_handle_mass_erase_command)
|
||||
|
||||
if (ambiqmicro_mass_erase(bank) == ERROR_OK) {
|
||||
/* set all sectors as erased */
|
||||
for (i = 0; i < bank->num_sectors; i++)
|
||||
for (unsigned int i = 0; i < bank->num_sectors; i++)
|
||||
bank->sectors[i].is_erased = 1;
|
||||
|
||||
command_print(CMD, "ambiqmicro mass erase complete");
|
||||
|
||||
Reference in New Issue
Block a user