mtd: rawnand: sunxi: fix ECC count register indexing
PATCH 1/1 mtd: rawnand: sunxi: fix ECC count register indexing
Each ECC error-count register contains four 8-bit correction counts. The register-offset helper already selects the register using the ECC block index divided by four, but field extraction shifts by the full block index. This produces shifts of 32 bits or more for each register after the first.
Use the block index modulo four when extracting the correction count.
--- drivers/mtd/nand/raw/sunxi_nand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/sunxi_nand.h +1 -1
@@ -167,7 +167,7 @@#define NFC_ECC_PAT_FOUND (x) BIT(x)#define NFC_ECC_PAT_FOUND_MSK (nfc) ((nfc)->caps->pat_found_mask) -#define NFC_ECC_ERR_CNT (b, x) (((x) >> ((b) * 8)) & 0xff) +#define NFC_ECC_ERR_CNT (b, x) (((x) >> (((b) % 4) * 8)) & 0xff)#define NFC_USER_DATA_LEN_MSK (step) \ (0xf << (((step) % NFC_REG_USER_DATA_LEN_CAPACITY) * 4))
Signature · 1 line
2.53.0
Le 15/07/2026 à 01:32, James Hilliard a écrit :
Quoted 10 lines
Each ECC error-count register contains four 8-bit correction counts. The register-offset helper already selects the register using the ECC block index divided by four, but field extraction shifts by the full block index. This produces shifts of 32 bits or more for each register after the first.
Use the block index modulo four when extracting the correction count.
Fixes 4ccae81cdadc ("mtd: nand: Add the sunxi NAND controller driver")Signed-off-by James Hilliard <[email protected]>
NB: While the fix is valid, it doesn't change anything at the end since the step is always 0 here. But it's better to have the right formula anyway.
Quoted 9 lines
--- drivers/mtd/nand/raw/sunxi_nand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/nand/raw/sunxi_nand.h +0
-0
drivers/mtd/nand/raw/sunxi_nand.h line 173
Quoted 8 lines
drivers/mtd/nand/raw/sunxi_nand.h +1
-1@@ -167,7 +167,7 @@#define NFC_ECC_PAT_FOUND (x) BIT(x)#define NFC_ECC_PAT_FOUND_MSK (nfc) ((nfc)->caps->pat_found_mask) -#define NFC_ECC_ERR_CNT (b, x) (((x) >> ((b) * 8)) & 0xff) +#define NFC_ECC_ERR_CNT (b, x) (((x) >> (((b) % 4) * 8)) & 0xff)#define NFC_USER_DATA_LEN_MSK (step) \ (0xf << (((step) % NFC_REG_USER_DATA_LEN_CAPACITY) * 4))
regards,
Richard