From 066aa24e85532b555e1fd34850327e7f7a570bf8 Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Mon, 10 Feb 2020 15:37:45 +0100 Subject: [PATCH] flash/nor/stm32l4x: Minor code cleanups Change-Id: I3053bbe888ac1f0a0593ef51bf9ca564f1cc27ec Signed-off-by: Marc Schink Reviewed-on: http://openocd.zylin.com/5449 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI Reviewed-by: Antonio Borneo --- src/flash/nor/stm32l4x.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index e9fb77e035..abbb75b466 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -142,7 +142,7 @@ struct stm32l4_part_info { }; struct stm32l4_flash_bank { - int probed; + bool probed; uint32_t idcode; int bank1_sectors; bool dual_bank_mode; @@ -282,7 +282,7 @@ FLASH_BANK_COMMAND_HANDLER(stm32l4_flash_bank_command) * Ask the flash infrastructure to ensure required alignment */ bank->write_start_alignment = bank->write_end_alignment = 8; - stm32l4_info->probed = 0; + stm32l4_info->probed = false; return ERROR_OK; } @@ -725,12 +725,11 @@ static int stm32l4_probe(struct flash_bank *bank) struct target *target = bank->target; struct stm32l4_flash_bank *stm32l4_info = bank->driver_priv; const struct stm32l4_part_info *part_info; - int i; uint16_t flash_size_in_kb = 0xffff; uint32_t device_id; uint32_t options; - stm32l4_info->probed = 0; + stm32l4_info->probed = false; /* read stm32 device id register */ int retval = stm32l4_read_idcode(bank, &stm32l4_info->idcode); @@ -875,7 +874,7 @@ static int stm32l4_probe(struct flash_bank *bank) return ERROR_FAIL; } - for (i = 0; i < bank->num_sectors; i++) { + for (int i = 0; i < bank->num_sectors; i++) { bank->sectors[i].offset = i * page_size; /* in dual bank configuration, if there is a gap between banks * we fix up the sector offset to consider this gap */ @@ -886,7 +885,7 @@ static int stm32l4_probe(struct flash_bank *bank) bank->sectors[i].is_protected = 1; } - stm32l4_info->probed = 1; + stm32l4_info->probed = true; return ERROR_OK; } @@ -976,8 +975,6 @@ err_lock: COMMAND_HANDLER(stm32l4_handle_mass_erase_command) { - int i; - if (CMD_ARGC < 1) { command_print(CMD, "stm32l4x mass_erase "); return ERROR_COMMAND_SYNTAX_ERROR; @@ -991,7 +988,7 @@ COMMAND_HANDLER(stm32l4_handle_mass_erase_command) retval = stm32l4_mass_erase(bank); if (retval == ERROR_OK) { /* set all sectors as erased */ - for (i = 0; i < bank->num_sectors; i++) + for (int i = 0; i < bank->num_sectors; i++) bank->sectors[i].is_erased = 1; command_print(CMD, "stm32l4x mass erase complete"); -- 2.30.2