Check for zero length in the legacy spi_flash_read() /
spi_flash_write() / spi_flash_erase() functions.
On zero length, return 0 immediately, don't call the underlying method.
Rationale:
- these legacy functions call the _read(), _write() and _erase() methods
of struct mtd
- the DM callers of these methods already check for zero length
- making all callers of these methods check for zero length makes it
possible to remove the check from implementations of these _read(),
_write() and _erase() methods
Signed-off-by: Marek Behún <marek.behun@nic.cz>
struct mtd_info *mtd = &flash->mtd;
size_t retlen;
+ if (!len)
+ return 0;
+
return mtd->_read(mtd, offset, len, &retlen, buf);
}
struct mtd_info *mtd = &flash->mtd;
size_t retlen;
+ if (!len)
+ return 0;
+
return mtd->_write(mtd, offset, len, &retlen, buf);
}
return -EINVAL;
}
+ if (!len)
+ return 0;
+
memset(&instr, 0, sizeof(instr));
instr.addr = offset;
instr.len = len;