Skip to contentSkip to conversation

mtd: nand: sunxi: fix sunxi_nfc_hw_ecc_read/write_chunk()

PATCH New Boris Brezillon 2 participants 3 messages Oct 20, 2015 – Nov 2, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mtd: nand: sunxi: fix sunxi_nfc_hw_ecc_read/write_chunk()

The sunxi_nfc_hw_ecc_read/write_chunk() functions try to avoid changing the column address if unnecessary, but the logic to determine whether it's necessary or not is currently wrong: it adds the ecc->bytes value to the current offset where it should actually add ecc->size.

Fixes 913821bdd211 "mtd: nand: sunxi: introduce sunxi_nfc_hw_ecc_read/write_chunk()"

---
 drivers/mtd/nand/sunxi_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/sunxi_nand.c +2 -2
index ef46ac6..96f7370 100644
@@ -588,7 +588,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
 
 	sunxi_nfc_read_buf(mtd, data, ecc->size);
 
-	if (data_off + ecc->bytes != oob_off)
+	if (data_off + ecc->size != oob_off)
 		nand->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_off, -1);
 
 	ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
@@ -679,7 +679,7 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd,
 	writel(sunxi_nfc_buf_to_user_data(oob),
 	       nfc->regs + NFC_REG_USER_DATA(0));
 
-	if (data_off + ecc->bytes != oob_off)
+	if (data_off + ecc->size != oob_off)
 		nand->cmdfunc(mtd, NAND_CMD_RNDIN, oob_off, -1);
 
 	ret = sunxi_nfc_wait_cmd_fifo_empty(nfc);
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/2 mtd: nand: sunxi: avoid retrieving data before ECC pass

The in-band data are copied twice: before ECC correction and after the ECC engine has fixed all the fixable bitflips.
Drop the useless memcpy_fromio operation by passing a NULL pointer when calling sunxi_nfc_read_buf().

---
 drivers/mtd/nand/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/sunxi_nand.c +1 -1
index 96f7370..8247118 100644
@@ -586,7 +586,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
 	if (*cur_off != data_off)
 		nand->cmdfunc(mtd, NAND_CMD_RNDOUT, data_off, -1);
 
-	sunxi_nfc_read_buf(mtd, data, ecc->size);
+	sunxi_nfc_read_buf(mtd, NULL, ecc->size);
 
 	if (data_off + ecc->size != oob_off)
 		nand->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_off, -1);
Signature · 1 line
2.1.4
#2 lore raw

PATCH 1/2 mtd: nand: sunxi: fix sunxi_nfc_hw_ecc_read/write_chunk()

In reply to Boris Brezillon
Quoted 7 lines · Boris Brezillon

The sunxi_nfc_hw_ecc_read/write_chunk() functions try to avoid changing the column address if unnecessary, but the logic to determine whether it's necessary or not is currently wrong: it adds the ecc->bytes value to the current offset where it should actually add ecc->size.

Fixes 913821bdd211 "mtd: nand: sunxi: introduce sunxi_nfc_hw_ecc_read/write_chunk()"

Pushed both to l2-mtd.git