flash/nor/stm32l4x: Minor code cleanups 49/5449/2
authorMarc Schink <dev@zapb.de>
Mon, 10 Feb 2020 14:37:45 +0000 (15:37 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 24 Feb 2020 10:26:02 +0000 (10:26 +0000)
Change-Id: I3053bbe888ac1f0a0593ef51bf9ca564f1cc27ec
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/5449
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
src/flash/nor/stm32l4x.c

index e9fb77e035c52afda149376ebae78bf140283fdb..abbb75b466b6a52968fa3a6988fda8f1706a78e6 100644 (file)
@@ -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 <STM32L4 bank>");
                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");

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)