ftl: fix is_group_erased() to read the proper offsets
This commit is contained in:
parent
538b3150a5
commit
f44581b648
1 changed files with 21 additions and 2 deletions
|
@ -14,8 +14,27 @@
|
|||
*/
|
||||
static int is_group_erased(struct ftl_map *map, uint32_t group)
|
||||
{
|
||||
return flash_is_erased(map->dev, group << map->log2_pages_per_group,
|
||||
UINT32_C(1) << map->log2_pages_per_group);
|
||||
char data[32];
|
||||
struct flash_dev *dev = map->dev;
|
||||
uint32_t addr = group << (map->log2_pages_per_group + map->log2_page_size);
|
||||
size_t i, nbytes, len = 1 << (map->log2_pages_per_group + map->log2_page_size);
|
||||
|
||||
while (len) {
|
||||
nbytes = min(32, len);
|
||||
|
||||
if (flash_read(dev, addr, data, nbytes) == 0)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < sizeof(data); ++i) {
|
||||
if (data[i] != 0xff)
|
||||
return 0;
|
||||
}
|
||||
|
||||
addr += nbytes;
|
||||
len -= nbytes;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Given the current user page, this function computes the page number of the
|
||||
|
|
Loading…
Add table
Reference in a new issue