Skip to content

Commit 0278e38

Browse files
author
Veijo Pesonen
committed
ExhaustibleBlockDevice: revert commit 10481f2
Reverts commit 10481f2 partially. Changes made to ExhaustibleBlockDevice hides simulated flash degradation which is the assumed behavior. Converted back to original behavior.
1 parent af4c8a9 commit 0278e38

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

features/storage/blockdevice/ExhaustibleBlockDevice.cpp

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,13 @@
2121
namespace mbed {
2222

2323
ExhaustibleBlockDevice::ExhaustibleBlockDevice(BlockDevice *bd, uint32_t erase_cycles)
24-
: _bd(bd), _erase_array(NULL), _programmable_array(NULL), _erase_cycles(erase_cycles),
25-
_init_ref_count(0), _is_initialized(false)
24+
: _bd(bd), _erase_array(NULL), _erase_cycles(erase_cycles), _init_ref_count(0), _is_initialized(false)
2625
{
2726
}
2827

2928
ExhaustibleBlockDevice::~ExhaustibleBlockDevice()
3029
{
3130
delete[] _erase_array;
32-
delete[] _programmable_array;
33-
}
34-
35-
uint32_t ExhaustibleBlockDevice::get_erase_cycles(bd_addr_t addr) const
36-
{
37-
if (!_is_initialized) {
38-
return 0;
39-
}
40-
return _erase_array[addr / get_erase_size()];
41-
}
42-
43-
void ExhaustibleBlockDevice::set_erase_cycles(bd_addr_t addr, uint32_t cycles)
44-
{
45-
if (!_is_initialized) {
46-
return;
47-
}
48-
_erase_array[addr / get_erase_size()] = cycles;
4931
}
5032

5133
int ExhaustibleBlockDevice::init()
@@ -70,13 +52,6 @@ int ExhaustibleBlockDevice::init()
7052
}
7153
}
7254

73-
if (!_programmable_array) {
74-
_programmable_array = new bool[_bd->size() / _bd->get_erase_size()];
75-
for (size_t i = 0; i < _bd->size() / _bd->get_erase_size(); i++) {
76-
_programmable_array[i] = true;
77-
}
78-
}
79-
8055
_is_initialized = true;
8156
return BD_ERROR_OK;
8257

@@ -133,20 +108,10 @@ int ExhaustibleBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_
133108
}
134109

135110
if (_erase_array[addr / get_erase_size()] == 0) {
136-
return BD_ERROR_DEVICE_ERROR;
137-
}
138-
139-
if (!_programmable_array[addr / get_erase_size()]) {
140-
return BD_ERROR_DEVICE_ERROR;
141-
}
142-
143-
int ret = _bd->program(buffer, addr, size);
144-
145-
if (ret == BD_ERROR_OK) {
146-
_programmable_array[addr / get_erase_size()] = false;
111+
return 0;
147112
}
148113

149-
return ret;
114+
return _bd->program(buffer, addr, size);
150115
}
151116

152117
int ExhaustibleBlockDevice::erase(bd_addr_t addr, bd_size_t size)
@@ -164,13 +129,13 @@ int ExhaustibleBlockDevice::erase(bd_addr_t addr, bd_size_t size)
164129
// use an erase cycle
165130
if (_erase_array[addr / eu_size] > 0) {
166131
_erase_array[addr / eu_size] -= 1;
132+
}
133+
134+
if (_erase_array[addr / eu_size] > 0) {
167135
int err = _bd->erase(addr, eu_size);
168136
if (err) {
169137
return err;
170138
}
171-
_programmable_array[addr / get_erase_size()] = true;
172-
} else {
173-
return BD_ERROR_DEVICE_ERROR;
174139
}
175140

176141
addr += eu_size;

features/storage/blockdevice/ExhaustibleBlockDevice.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ class ExhaustibleBlockDevice : public BlockDevice {
158158
private:
159159
BlockDevice *_bd;
160160
uint32_t *_erase_array;
161-
bool *_programmable_array;
162161
uint32_t _erase_cycles;
163162
uint32_t _init_ref_count;
164163
bool _is_initialized;

0 commit comments

Comments
 (0)