flash/nor: Use proper data types in driver API
[openocd.git] / src / flash / nor / stm32l4x.c
index 94fcd3226de530b88b8b4d88a27b89fe67265d8f..edd013048b25fad4ad52f96e6aeeaa0e42ea40e4 100644 (file)
@@ -129,7 +129,7 @@ struct stm32l4_part_info {
 struct stm32l4_flash_bank {
        bool probed;
        uint32_t idcode;
-       int bank1_sectors;
+       unsigned int bank1_sectors;
        bool dual_bank_mode;
        int hole_sectors;
        uint32_t user_bank_size;
@@ -548,7 +548,7 @@ static int stm32l4_protect_check(struct flash_bank *bank)
        const uint8_t wrp2b_start = wrp2br & stm32l4_info->wrpxxr_mask;
        const uint8_t wrp2b_end = (wrp2br >> 16) & stm32l4_info->wrpxxr_mask;
 
-       for (int i = 0; i < bank->num_sectors; i++) {
+       for (unsigned int i = 0; i < bank->num_sectors; i++) {
                if (i < stm32l4_info->bank1_sectors) {
                        if (((i >= wrp1a_start) &&
                                 (i <= wrp1a_end)) ||
@@ -573,13 +573,13 @@ static int stm32l4_protect_check(struct flash_bank *bank)
        return ERROR_OK;
 }
 
-static int stm32l4_erase(struct flash_bank *bank, int first, int last)
+static int stm32l4_erase(struct flash_bank *bank, unsigned int first,
+               unsigned int last)
 {
        struct stm32l4_flash_bank *stm32l4_info = bank->driver_priv;
-       int i;
        int retval, retval2;
 
-       assert((0 <= first) && (first <= last) && (last < bank->num_sectors));
+       assert((first <= last) && (last < bank->num_sectors));
 
        if (bank->target->state != TARGET_HALTED) {
                LOG_ERROR("Target not halted");
@@ -601,7 +601,7 @@ static int stm32l4_erase(struct flash_bank *bank, int first, int last)
        4. Wait for the BSY bit to be cleared
         */
 
-       for (i = first; i <= last; i++) {
+       for (unsigned int i = first; i <= last; i++) {
                uint32_t erase_flags;
                erase_flags = FLASH_PER | FLASH_STRT;
 
@@ -631,7 +631,8 @@ err_lock:
        return retval2;
 }
 
-static int stm32l4_protect(struct flash_bank *bank, int set, int first, int last)
+static int stm32l4_protect(struct flash_bank *bank, int set, unsigned int first,
+               unsigned int last)
 {
        struct target *target = bank->target;
        struct stm32l4_flash_bank *stm32l4_info = bank->driver_priv;
@@ -1053,7 +1054,7 @@ static int stm32l4_probe(struct flash_bank *bank)
                return ERROR_FAIL;
        }
 
-       for (int i = 0; i < bank->num_sectors; i++) {
+       for (unsigned int i = 0; i < bank->num_sectors; i++) {
                bank->sectors[i].offset = i * page_size_kb * 1024;
                /* in dual bank configuration, if there is a gap between banks
                 * we fix up the sector offset to consider this gap */
@@ -1169,7 +1170,7 @@ COMMAND_HANDLER(stm32l4_handle_mass_erase_command)
        retval = stm32l4_mass_erase(bank);
        if (retval == ERROR_OK) {
                /* set all sectors as erased */
-               for (int 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, "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)