Skip to contentSkip to conversation

mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper

RFC PATCH In review Brian Norris 3 participants 4 messages Sep 29, 2015 – Oct 26, 2015

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

RFC PATCH 1/1 mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper

---
I forgot about this feedback. How does this patch look? Just compile tested.

 drivers/mtd/nand/vf610_nfc.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/mtd/nand/vf610_nfc.c +3 -11
index 42dad8e4b26f..598faf655f5b 100644
@@ -560,7 +560,6 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
 	u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS;
 	u8 ecc_status;
 	u8 ecc_count;
-	int flips;
 	int flips_threshold = nfc->chip.ecc.strength / 2;
 
 	ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff;
@@ -577,16 +576,9 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
 	 * On an erased page, bit count (including OOB) should be zero or
 	 * at least less then half of the ECC strength.
 	 */
-	flips = count_written_bits(dat, nfc->chip.ecc.size, flips_threshold);
-	flips += count_written_bits(oob, mtd->oobsize, flips_threshold);
-
-	if (unlikely(flips > flips_threshold))
-		return -EINVAL;
-
-	/* Erased page. */
-	memset(dat, 0xff, nfc->chip.ecc.size);
-	memset(oob, 0xff, mtd->oobsize);
-	return flips;
+	return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob,
+					   mtd->oobsize, NULL, 0,
+					   flips_threshold);
 }
 
 static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · On Tue, 29 Sep 2015 14:11:56 -0700 Brian Norris <[email protected]>…

---
I forgot about this feedback. How does this patch look? Just compile tested.

Looks good to me, but I can't test it either :-).

Quoted 36 lines
 drivers/mtd/nand/vf610_nfc.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/mtd/nand/vf610_nfc.c +3 -11
index 42dad8e4b26f..598faf655f5b 100644
@@ -560,7 +560,6 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
 	u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS;
 	u8 ecc_status;
 	u8 ecc_count;
-	int flips;
 	int flips_threshold = nfc->chip.ecc.strength / 2;
 
 	ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff;
@@ -577,16 +576,9 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
 	 * On an erased page, bit count (including OOB) should be zero or
 	 * at least less then half of the ECC strength.
 	 */
-	flips = count_written_bits(dat, nfc->chip.ecc.size, flips_threshold);
-	flips += count_written_bits(oob, mtd->oobsize, flips_threshold);
-
-	if (unlikely(flips > flips_threshold))
-		return -EINVAL;
-
-	/* Erased page. */
-	memset(dat, 0xff, nfc->chip.ecc.size);
-	memset(oob, 0xff, mtd->oobsize);
-	return flips;
+	return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob,
+					   mtd->oobsize, NULL, 0,
+					   flips_threshold);
 }
 
 static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 3 lines
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw
Quoted 8 lines · Brian Norris
Quoted 7 lines · Boris Brezillon
Quoted 3 lines · On Tue, 29 Sep 2015 14:11:56 -0700 Brian Norris <[email protected]>…

---
I forgot about this feedback. How does this patch look? Just compile tested.

Quoted 7 lines
Quoted 3 lines

Looks good to me, but I can't test it either :-).

Seeing as this came up during review, and I see no objections...

Applied to l2-mtd.git

Hi Brian,

Yeah, sorry, I wanted test that patch but somehow slipped through. Compiled l2-mtd master with that patch applied for my board, looks good to me! Thx

--
Stefan