flash/nor: Do not update 'is_erased'
[fw/openocd] / src / flash / nor / stm32h7x.c
index 16ab6aeb7eba4286b0f6b86e59de431e421c5f3e..89ba75dad8a34c2cd656cc9b430969c2cf9084e7 100644 (file)
@@ -512,7 +512,6 @@ static int stm32x_erase(struct flash_bank *bank, unsigned int first,
                        LOG_ERROR("erase time-out or operation error sector %u", i);
                        goto flash_lock;
                }
-               bank->sectors[i].is_erased = 1;
        }
 
 flash_lock:
@@ -879,7 +878,7 @@ static int stm32x_probe(struct flash_bank *bank)
        bank->sectors = alloc_block_array(0, stm32x_info->part_info->page_size_kb * 1024,
                        bank->num_sectors);
 
-       if (bank->sectors == NULL) {
+       if (!bank->sectors) {
                LOG_ERROR("failed to allocate bank sectors");
                return ERROR_FAIL;
        }
@@ -896,7 +895,7 @@ static int stm32x_probe(struct flash_bank *bank)
        bank->prot_blocks = alloc_block_array(0, stm32x_info->part_info->page_size_kb * wpsn * 1024,
                        bank->num_prot_blocks);
 
-       if (bank->prot_blocks == NULL) {
+       if (!bank->prot_blocks) {
                LOG_ERROR("failed to allocate bank prot_block");
                return ERROR_FAIL;
        }
@@ -937,7 +936,7 @@ static int stm32x_get_info(struct flash_bank *bank, struct command_invocation *c
                        if (rev_id == info->revs[i].rev)
                                rev_str = info->revs[i].str;
 
-               if (rev_str != NULL) {
+               if (rev_str) {
                        command_print_sameline(cmd, "%s - Rev: %s",
                                stm32x_info->part_info->device_str, rev_str);
                } else {
@@ -1087,15 +1086,10 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command)
                return retval;
 
        retval = stm32x_mass_erase(bank);
-       if (retval == ERROR_OK) {
-               /* set all sectors as erased */
-               for (unsigned int i = 0; i < bank->num_sectors; i++)
-                       bank->sectors[i].is_erased = 1;
-
+       if (retval == ERROR_OK)
                command_print(CMD, "stm32h7x mass erase complete");
-       } else {
+       else
                command_print(CMD, "stm32h7x mass erase failed");
-       }
 
        return retval;
 }