Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions drivers/flash/flash_sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,12 @@ static bool sam_flash_erase_foreach_page(const struct flash_pages_info *info, vo
/* Check if we've reached the end of pages to erase */
if (info->start_offset >= erase_data->section_end) {
/* Succeeded, stop iterating */
erase_data->succeeded = true;
return false;
}

if (sam_flash_unlock_page(dev, info) < 0) {
/* Failed to unlock page, stop iterating */
return false;
}

if (sam_flash_erase_page(dev, info) < 0) {
/* Failed to erase page, stop iterating */
if (sam_flash_unlock_page(dev, info) || sam_flash_erase_page(dev, info)) {
/* Failed to unlock page and erase page, stop iterating */
erase_data->succeeded = false;
return false;
}

Expand Down Expand Up @@ -436,7 +431,7 @@ static int sam_flash_erase(const struct device *dev, off_t offset, size_t size)
key = k_spin_lock(&sam_data->lock);
sam_data->erase_data.section_start = offset;
sam_data->erase_data.section_end = offset + size;
sam_data->erase_data.succeeded = false;
sam_data->erase_data.succeeded = true;
flash_page_foreach(dev, sam_flash_erase_foreach_page, sam_data);
if (!sam_data->erase_data.succeeded) {
k_spin_unlock(&sam_data->lock, key);
Expand Down
2 changes: 1 addition & 1 deletion dts/arm/atmel/samx7xx21.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
flash-controller@400e0c00 {
flash0: flash@400000 {
reg = <0x00400000 DT_SIZE_K(2048)>;
erase-blocks = <&eefc 8 2048>, <&eefc 252 8192>;
erase-blocks = <&eefc 8 2048>, <&eefc 254 8192>;
};
};
};
Expand Down
Loading