Skip to content

Commit e708789

Browse files
committed
mtd: spinand: Fix MTD_OPS_AUTO_OOB requests
The initial change breaking the logic is commit 3d1f08b ("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 868cbe2 ("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: 868cbe2 ("mtd: spinand: Fix OOB read") Reported-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20210107083813.24283-1-miquel.raynal@bootlin.com
1 parent 18f6261 commit e708789

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

drivers/mtd/nand/spi/core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
343343
const struct nand_page_io_req *req)
344344
{
345345
struct nand_device *nand = spinand_to_nand(spinand);
346+
struct mtd_info *mtd = spinand_to_mtd(spinand);
346347
struct spi_mem_dirmap_desc *rdesc;
347348
unsigned int nbytes = 0;
348349
void *buf = NULL;
@@ -382,9 +383,16 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
382383
memcpy(req->databuf.in, spinand->databuf + req->dataoffs,
383384
req->datalen);
384385

385-
if (req->ooblen)
386-
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
387-
req->ooblen);
386+
if (req->ooblen) {
387+
if (req->mode == MTD_OPS_AUTO_OOB)
388+
mtd_ooblayout_get_databytes(mtd, req->oobbuf.in,
389+
spinand->oobbuf,
390+
req->ooboffs,
391+
req->ooblen);
392+
else
393+
memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
394+
req->ooblen);
395+
}
388396

389397
return 0;
390398
}

0 commit comments

Comments
 (0)