X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Flpc288x.c;h=1c10e50157a7300626df0c6878432f267d408189;hb=4f371e8eed5c4e479d326cf09f7827884c23b947;hp=afa8d79489ebbe085c701f6bd36da5e7ecb84a16;hpb=63fcef493ab23e6f00a8e815c4f59688a088d285;p=openocd.git diff --git a/src/flash/nor/lpc288x.c b/src/flash/nor/lpc288x.c index afa8d79489..1c10e50157 100644 --- a/src/flash/nor/lpc288x.c +++ b/src/flash/nor/lpc288x.c @@ -232,17 +232,17 @@ static uint32_t lpc288x_system_ready(struct flash_bank *bank) return ERROR_OK; } -static int lpc288x_erase(struct flash_bank *bank, int first, int last) +static int lpc288x_erase(struct flash_bank *bank, unsigned int first, + unsigned int last) { uint32_t status; - int sector; struct target *target = bank->target; status = lpc288x_system_ready(bank); /* probed? halted? */ if (status != ERROR_OK) return status; - if ((first < 0) || (last < first) || (last >= bank->num_sectors)) { + if ((last < first) || (last >= bank->num_sectors)) { LOG_INFO("Bad sector range"); return ERROR_FLASH_SECTOR_INVALID; } @@ -250,7 +250,7 @@ static int lpc288x_erase(struct flash_bank *bank, int first, int last) /* Configure the flash controller timing */ lpc288x_set_flash_clk(bank); - for (sector = first; sector <= last; sector++) { + for (unsigned int sector = first; sector <= last; sector++) { if (lpc288x_wait_status_busy(bank, 1000) != ERROR_OK) return ERROR_FLASH_OPERATION_FAILED; @@ -272,7 +272,6 @@ static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_ struct target *target = bank->target; uint32_t bytes_remaining = count; uint32_t first_sector, last_sector, sector, page; - int i; /* probed? halted? */ status = lpc288x_system_ready(bank); @@ -283,7 +282,7 @@ static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_ first_sector = last_sector = 0xffffffff; /* validate the write range... */ - for (i = 0; i < bank->num_sectors; i++) { + for (unsigned int i = 0; i < bank->num_sectors; i++) { if ((offset >= bank->sectors[i].offset) && (offset < (bank->sectors[i].offset + bank->sectors[i].size)) && (first_sector == 0xffffffff)) { @@ -379,9 +378,10 @@ static int lpc288x_probe(struct flash_bank *bank) return ERROR_OK; } -static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last) +static int lpc288x_protect(struct flash_bank *bank, int set, unsigned int first, + unsigned int last) { - int lockregion, status; + int status; uint32_t value; struct target *target = bank->target; @@ -390,18 +390,18 @@ static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last if (status != ERROR_OK) return status; - if ((first < 0) || (last < first) || (last >= bank->num_sectors)) + if ((last < first) || (last >= bank->num_sectors)) return ERROR_FLASH_SECTOR_INVALID; /* Configure the flash controller timing */ lpc288x_set_flash_clk(bank); - for (lockregion = first; lockregion <= last; lockregion++) { + for (unsigned int lockregion = first; lockregion <= last; lockregion++) { if (set) { - /* write an odd value to base addy to protect... */ + /* write an odd value to base address to protect... */ value = 0x01; } else { - /* write an even value to base addy to unprotect... */ + /* write an even value to base address to unprotect... */ value = 0x00; } target_write_u32(target, bank->sectors[lockregion].offset, value); @@ -412,7 +412,7 @@ static int lpc288x_protect(struct flash_bank *bank, int set, int first, int last return ERROR_OK; } -struct flash_driver lpc288x_flash = { +const struct flash_driver lpc288x_flash = { .name = "lpc288x", .flash_bank_command = lpc288x_flash_bank_command, .erase = lpc288x_erase,