@@ -167,11 +167,7 @@ int TDBStore::erase_erase_unit(uint8_t area, uint32_t offset)
167
167
uint32_t bd_offset = _area_params[area].address + offset;
168
168
uint32_t eu_size = _buff_bd->get_erase_size (bd_offset);
169
169
170
- int os_ret = _buff_bd->erase (bd_offset, eu_size);
171
- if (os_ret) {
172
- return MBED_ERROR_WRITE_FAILED;
173
- }
174
- return MBED_SUCCESS;
170
+ return _buff_bd->erase (bd_offset, eu_size);
175
171
}
176
172
177
173
void TDBStore::calc_area_params ()
@@ -1498,29 +1494,19 @@ int TDBStore::is_erase_unit_erased(uint8_t area, uint32_t offset, bool &erased)
1498
1494
int TDBStore::check_erase_before_write (uint8_t area, uint32_t offset, uint32_t size, bool force_check)
1499
1495
{
1500
1496
// In order to save init time, we don't check that the entire area is erased.
1501
- // Instead, whenever reaching an erase unit start, check that it's erased, and if not -
1502
- // erase it.
1497
+ // Instead, whenever reaching an erase unit start erase it.
1503
1498
1504
1499
while (size) {
1505
1500
uint32_t dist, offset_from_start;
1506
1501
int ret;
1507
1502
offset_in_erase_unit (area, offset, offset_from_start, dist);
1508
1503
uint32_t chunk = std::min (size, dist);
1509
1504
1510
- if (!offset_from_start || force_check) {
1511
- // We're at the start of an erase unit. Here (and only here, if not forced),
1512
- // check if it's erased.
1513
- bool erased;
1514
- ret = is_erase_unit_erased (area, offset, erased);
1515
- if (ret) {
1505
+ if (offset_from_start == 0 || force_check) {
1506
+ ret = erase_erase_unit (area, offset - offset_from_start);
1507
+ if (ret != MBED_SUCCESS) {
1516
1508
return MBED_ERROR_WRITE_FAILED;
1517
1509
}
1518
- if (!erased) {
1519
- ret = erase_erase_unit (area, offset - offset_from_start);
1520
- if (ret) {
1521
- return MBED_ERROR_WRITE_FAILED;
1522
- }
1523
- }
1524
1510
}
1525
1511
offset += chunk;
1526
1512
size -= chunk;
0 commit comments