1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/mrd_spi_nor: fix read spanning pages

This commit is contained in:
Vincent Dupont 2019-02-28 16:57:27 +01:00
parent 49358e2763
commit c077c07017

View File

@ -420,17 +420,9 @@ static int mtd_spi_nor_read(mtd_dev_t *mtd, void *dest, uint32_t addr, uint32_t
if (addr > chipsize) {
return -EOVERFLOW;
}
if (size > mtd->page_size) {
size = mtd->page_size;
}
if ((addr + size) > chipsize) {
size = chipsize - addr;
}
uint32_t page_addr_mask = dev->page_addr_mask;
if ((addr & page_addr_mask) != ((addr + size - 1) & page_addr_mask)) {
/* Reads across page boundaries must be split */
size = mtd->page_size - (addr & ~(page_addr_mask));
}
if (size == 0) {
return 0;
}