mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mtd: spinand: fix zero oobavail when no ECC engine is used
Commit00c15b78b4("mtd: spinand: Allow the case where there is no ECC engine") made the OOB free bytes count conditional on having an ECC engine so that probing would not fail when none is requested. However mtd->oobavail is still assigned from ret just after that block, and ret is 0 there, so the device ends up advertising no available OOB bytes at all. mtd_oobavail() returns mtd->oobavail for MTD_OPS_AUTO_OOB, so a zero value makes every automatic OOB access fail with -EINVAL. JFFS2 fares worse: it keeps its cleanmarker in the OOB area on NAND and refuses to mount outright, reporting "inconsistent device description". No ECC engine also means no ooblayout was ever installed, which would make the count return -ENOTSUPP, so install the same fallback layout the on-die path already uses before counting unconditionally. Fixes:00c15b78b4("mtd: spinand: Allow the case where there is no ECC engine") Cc: stable@vger.kernel.org Signed-off-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
parent
b890e61637
commit
636fe10d8f
|
|
@ -1996,12 +1996,17 @@ static int spinand_init(struct spinand_device *spinand)
|
|||
goto err_cleanup_ecc_engine;
|
||||
}
|
||||
|
||||
if (nand->ecc.engine) {
|
||||
ret = mtd_ooblayout_count_freebytes(mtd);
|
||||
if (ret < 0)
|
||||
goto err_cleanup_ecc_engine;
|
||||
if (!nand->ecc.engine) {
|
||||
if (spinand->eccinfo.ooblayout)
|
||||
mtd_set_ooblayout(mtd, spinand->eccinfo.ooblayout);
|
||||
else
|
||||
mtd_set_ooblayout(mtd, &spinand_noecc_ooblayout);
|
||||
}
|
||||
|
||||
ret = mtd_ooblayout_count_freebytes(mtd);
|
||||
if (ret < 0)
|
||||
goto err_cleanup_ecc_engine;
|
||||
|
||||
mtd->oobavail = ret;
|
||||
|
||||
/* Propagate ECC information to mtd_info */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user