Message ID | tencent_0C26A1F1DE0E8F407935B412AE273DBC7108@qq.com |
---|---|
State | Accepted |
Commit | b2be69516662957a9cb1b330d640898f262f7f0e |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show |
Series | mtd: spinand: macronix: Fix ECC Status Read | expand |
On Sun, Sep 5, 2021 at 8:12 PM <li.haolin@qq.com> wrote: > > From: Haolin Li <li.haolin@qq.com> > > According to datasheet, the upper four bits are reserved or used for > reflecting the ECC status of the accumulated pages. The error bits > number for the worst segment of the current page is encoded on lower > four bits. Fix it by masking the upper bits. > > This same issue has been already fixed in the linux kernel by: > "mtd: spinand: macronix: Fix ECC Status Read" > (sha1: f4cb4d7b46f6409382fd981eec9556e1f3c1dc5d) > > Apply the same fix in the U-Boot driver. > > Signed-off-by: Haolin Li <li.haolin@qq.com> > --- Applied to u-boot-spi/master
diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c index f4a8e81639..6d643a8000 100644 --- a/drivers/mtd/nand/spi/macronix.c +++ b/drivers/mtd/nand/spi/macronix.c @@ -14,6 +14,8 @@ #include <linux/mtd/spinand.h> #define SPINAND_MFR_MACRONIX 0xC2 +#define MACRONIX_ECCSR_MASK 0x0F + static SPINAND_OP_VARIANTS(read_cache_variants, SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0), @@ -59,7 +61,13 @@ static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr) SPI_MEM_OP_DUMMY(1, 1), SPI_MEM_OP_DATA_IN(1, eccsr, 1)); - return spi_mem_exec_op(spinand->slave, &op); + int ret = spi_mem_exec_op(spinand->slave, &op); + + if (ret) + return ret; + + *eccsr &= MACRONIX_ECCSR_MASK; + return 0; } static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,