From b66c344c7b848fc337df833c6670dfc07fbde73c Mon Sep 17 00:00:00 2001 From: Jon Lin Date: Wed, 5 Jul 2023 14:24:05 +0800 Subject: [PATCH] mtd: spinand: unim: Fix the error method for judging flash ECC The former method makes ECC effective value decreased from 4 to 1. Change-Id: Ie5f37e291166661def40db015eac63c003719785 Signed-off-by: Jon Lin --- drivers/mtd/nand/spi/unim.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/spi/unim.c b/drivers/mtd/nand/spi/unim.c index 659921e2a095..ee78420123eb 100644 --- a/drivers/mtd/nand/spi/unim.c +++ b/drivers/mtd/nand/spi/unim.c @@ -69,12 +69,13 @@ static const struct mtd_ooblayout_ops tx25g01_ooblayout = { static int tx25g01_ecc_get_status(struct spinand_device *spinand, u8 status) { - u8 eccsr = (status & GENMASK(6, 4)) >> 2; + struct nand_device *nand = spinand_to_nand(spinand); + u8 eccsr = (status & GENMASK(6, 4)) >> 4; - if (eccsr <= 7) + if (eccsr < 4) return eccsr; - else if (eccsr == 12) - return 8; + else if (eccsr == 4) + return nanddev_get_ecc_requirements(nand)->strength; else return -EBADMSG; }