spi: flash: correct wrap-around.

This commit is contained in:
S.J.R. van Schaik 2017-06-26 12:18:44 +02:00
parent 3395eb1a82
commit 159a4e83b4

View file

@ -130,7 +130,7 @@ static size_t spi_flash_write(struct flash_dev *dev, uint32_t addr,
spi_flash_addr(cmd, addr);
nbytes = min(len, 32);
nbytes = nbytes - ((addr + nbytes) & 0xff);
nbytes = min(nbytes, align_up(addr + 1, ilog2(256)) - addr);
memmove(cmd + 4, data, nbytes);
spi_tx_rx(spi_dev, NULL, 0, cmd, 4 + nbytes);