Commit e708789c authored by Miquel Raynal's avatar Miquel Raynal

mtd: spinand: Fix MTD_OPS_AUTO_OOB requests

The initial change breaking the logic is
commit 3d1f08b0 ("mtd: spinand: Use the external ECC engine logic")
It inadvertently dropped proper OOB support while doing something
else.

Shortly later, half of it got re-integrated by
commit 868cbe2a ("mtd: spinand: Fix OOB read")
(pointing by the way to a  more early change which had nothing to do
with the issue). Problem is, this commit failed to revert the faulty
change entirely and missed the logic handling MTD_OPS_AUTO_OOB
requests.

Let's fix this mess by re-inserting the missing part now.

Fixes: 868cbe2a ("mtd: spinand: Fix OOB read")
Reported-by: default avatarFelix Fietkau <nbd@nbd.name>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210107083813.24283-1-miquel.raynal@bootlin.com
parent 18f62614
...@@ -343,6 +343,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, ...@@ -343,6 +343,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
const struct nand_page_io_req *req) const struct nand_page_io_req *req)
{ {
struct nand_device *nand = spinand_to_nand(spinand); struct nand_device *nand = spinand_to_nand(spinand);
struct mtd_info *mtd = spinand_to_mtd(spinand);
struct spi_mem_dirmap_desc *rdesc; struct spi_mem_dirmap_desc *rdesc;
unsigned int nbytes = 0; unsigned int nbytes = 0;
void *buf = NULL; void *buf = NULL;
...@@ -382,9 +383,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, ...@@ -382,9 +383,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
memcpy(req->databuf.in, spinand->databuf + req->dataoffs, memcpy(req->databuf.in, spinand->databuf + req->dataoffs,
req->datalen); req->datalen);
if (req->ooblen) if (req->ooblen) {
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs, if (req->mode == MTD_OPS_AUTO_OOB)
req->ooblen); mtd_ooblayout_get_databytes(mtd, req->oobbuf.in,
spinand->oobbuf,
req->ooboffs,
req->ooblen);
else
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
req->ooblen);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment