flash/nor: Use proper data types in driver API
[openocd.git] / src / flash / nor / kinetis.c
index 084e009ee66b49527798bf7dc564617f133b9b83..6753f0fe303126833e63e58cd772a925429ff3df 100644 (file)
@@ -1338,7 +1338,8 @@ static int kinetis_write_block(struct flash_bank *bank, const uint8_t *buffer,
        return retval;
 }
 
-static int kinetis_protect(struct flash_bank *bank, int set, int first, int last)
+static int kinetis_protect(struct flash_bank *bank, int set, unsigned int first,
+               unsigned int last)
 {
        if (allow_fcf_writes) {
                LOG_ERROR("Protection setting is possible with 'kinetis fcf_source protection' only!");
@@ -1350,7 +1351,7 @@ static int kinetis_protect(struct flash_bank *bank, int set, int first, int last
                return ERROR_FLASH_BANK_INVALID;
        }
 
-       for (int i = first; i < bank->num_prot_blocks && i <= last; i++)
+       for (unsigned int i = first; i < bank->num_prot_blocks && i <= last; i++)
                bank->prot_blocks[i].is_protected = set;
 
        LOG_INFO("Protection bits will be written at the next FCF sector erase or write.");
@@ -1392,7 +1393,7 @@ static int kinetis_protect_check(struct flash_bank *bank)
        }
 
        b = k_bank->protection_block;
-       for (int i = 0; i < bank->num_prot_blocks; i++) {
+       for (unsigned int i = 0; i < bank->num_prot_blocks; i++) {
                if ((fprot >> b) & 1)
                        bank->prot_blocks[i].is_protected = 0;
                else
@@ -1439,7 +1440,7 @@ static int kinetis_fill_fcf(struct flash_bank *bank, uint8_t *fcf)
                assert(bank_iter->prot_blocks);
 
                if (k_bank->flash_class == FC_PFLASH) {
-                       for (int i = 0; i < bank_iter->num_prot_blocks; i++) {
+                       for (unsigned int i = 0; i < bank_iter->num_prot_blocks; i++) {
                                if (bank_iter->prot_blocks[i].is_protected == 1)
                                        fprot &= ~pflash_bit;
 
@@ -1447,7 +1448,7 @@ static int kinetis_fill_fcf(struct flash_bank *bank, uint8_t *fcf)
                        }
 
                } else if (k_bank->flash_class == FC_FLEX_NVM) {
-                       for (int i = 0; i < bank_iter->num_prot_blocks; i++) {
+                       for (unsigned int i = 0; i < bank_iter->num_prot_blocks; i++) {
                                if (bank_iter->prot_blocks[i].is_protected == 1)
                                        fdprot &= ~dflash_bit;
 
@@ -1616,7 +1617,8 @@ static void kinetis_invalidate_flash_cache(struct kinetis_chip *k_chip)
 }
 
 
-static int kinetis_erase(struct flash_bank *bank, int first, int last)
+static int kinetis_erase(struct flash_bank *bank, unsigned int first,
+               unsigned int last)
 {
        int result;
        struct kinetis_flash_bank *k_bank = bank->driver_priv;
@@ -1639,13 +1641,13 @@ static int kinetis_erase(struct flash_bank *bank, int first, int last)
         * requested erase is PFlash or NVM and encompasses the entire
         * block.  Should be quicker.
         */
-       for (int i = first; i <= last; i++) {
+       for (unsigned int i = first; i <= last; i++) {
                /* set command and sector address */
                result = kinetis_ftfx_command(bank->target, FTFx_CMD_SECTERASE, k_bank->prog_base + bank->sectors[i].offset,
                                0, 0, 0, 0,  0, 0, 0, 0,  NULL);
 
                if (result != ERROR_OK) {
-                       LOG_WARNING("erase sector %d failed", i);
+                       LOG_WARNING("erase sector %u failed", i);
                        return ERROR_FLASH_OPERATION_FAILED;
                }
 
@@ -2689,7 +2691,7 @@ static int kinetis_probe(struct flash_bank *bank)
 
                if (bank->size > limit) {
                        bank->size = limit;
-                       LOG_DEBUG("FlexNVM bank %d limited to 0x%08" PRIx32 " due to active EEPROM backup",
+                       LOG_DEBUG("FlexNVM bank %u limited to 0x%08" PRIx32 " due to active EEPROM backup",
                                k_bank->bank_number, limit);
                }
 
@@ -2698,7 +2700,7 @@ static int kinetis_probe(struct flash_bank *bank)
                         k_bank->bank_number, size_k, k_bank->prog_base, k_bank->sector_size);
 
        } else {
-               LOG_ERROR("Cannot determine parameters for bank %d, only %d banks on device",
+               LOG_ERROR("Cannot determine parameters for bank %u, only %u banks on device",
                                k_bank->bank_number, num_blocks);
                return ERROR_FLASH_BANK_INVALID;
        }
@@ -2732,7 +2734,7 @@ static int kinetis_probe(struct flash_bank *bank)
        }
 
        if (k_bank->sector_size == 0) {
-               LOG_ERROR("Unknown sector size for bank %d", bank->bank_number);
+               LOG_ERROR("Unknown sector size for bank %u", bank->bank_number);
                return ERROR_FLASH_BANK_INVALID;
        }
 
@@ -2827,7 +2829,7 @@ static int kinetis_blank_check(struct flash_bank *bank)
 
                if (block_dirty) {
                        /* the whole bank is not erased, check sector-by-sector */
-                       for (int i = 0; i < bank->num_sectors; i++) {
+                       for (unsigned int i = 0; i < bank->num_sectors; i++) {
                                /* normal margin */
                                result = kinetis_ftfx_command(bank->target, FTFx_CMD_SECTSTAT,
                                                k_bank->prog_base + bank->sectors[i].offset,
@@ -2843,7 +2845,7 @@ static int kinetis_blank_check(struct flash_bank *bank)
                        }
                } else {
                        /* the whole bank is erased, update all sectors */
-                       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;
                }
        } else {

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)