mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
drivers/mrd_spi_nor: fix read spanning pages
This commit is contained in:
parent
49358e2763
commit
c077c07017
@ -420,17 +420,9 @@ static int mtd_spi_nor_read(mtd_dev_t *mtd, void *dest, uint32_t addr, uint32_t
|
|||||||
if (addr > chipsize) {
|
if (addr > chipsize) {
|
||||||
return -EOVERFLOW;
|
return -EOVERFLOW;
|
||||||
}
|
}
|
||||||
if (size > mtd->page_size) {
|
|
||||||
size = mtd->page_size;
|
|
||||||
}
|
|
||||||
if ((addr + size) > chipsize) {
|
if ((addr + size) > chipsize) {
|
||||||
size = chipsize - addr;
|
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) {
|
if (size == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user