From: James Hilliard <james.hilliard1@gmail.com>
To: u-boot@lists.denx.de
Cc: James Hilliard <james.hilliard1@gmail.com>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Michael Trimarchi <michael@amarulasolutions.com>,
Tom Rini <trini@konsulko.com>,
Richard Genoud <richard.genoud@bootlin.com>,
Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
Hans de Goede <hdegoede@redhat.com>,
Boris Brezillon <bbrezillon@kernel.org>
Subject: [PATCH] mtd: rawnand: sunxi: fix ECC count register indexing
Date: Tue, 14 Jul 2026 17:32:55 -0600 [thread overview]
Message-ID: <20260714233259.508396-1-james.hilliard1@gmail.com> (raw)
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 <james.hilliard1@gmail.com>
---
drivers/mtd/nand/raw/sunxi_nand.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/sunxi_nand.h b/drivers/mtd/nand/raw/sunxi_nand.h
index 1b2c514852d..96b65c52685 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.h
+++ b/drivers/mtd/nand/raw/sunxi_nand.h
@@ -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))
--
2.53.0
next reply other threads:[~2026-07-14 23:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 23:32 James Hilliard [this message]
2026-07-15 7:48 ` [PATCH] mtd: rawnand: sunxi: fix ECC count register indexing Richard GENOUD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260714233259.508396-1-james.hilliard1@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=bbrezillon@kernel.org \
--cc=dario.binacchi@amarulasolutions.com \
--cc=hdegoede@redhat.com \
--cc=michael@amarulasolutions.com \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=richard.genoud@bootlin.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox