ftl: fix order of preliminary checks

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent acc18a5253
commit 631cc1e33a
  1. 10
      source/ftl/ftl.c

@ -25,6 +25,11 @@ size_t ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va)
int ret;
uint32_t mask, offset, page;
if (!data)
return 0;
len = min(len, (1 << map->log2_page_size) - offset);
mask = ((1 << map->log2_page_size) - 1);
offset = va & mask;
va >>= map->log2_page_size;
@ -34,11 +39,6 @@ size_t ftl_read(struct ftl_map *map, void *data, size_t len, uint32_t va)
return len;
}
if (!data)
return 0;
len = min(len, (1 << map->log2_page_size) - offset);
return flash_read(map->dev, (page << map->log2_page_size) + offset, data,
len);
}

Loading…
Cancel
Save