diff options
-rw-r--r-- | drivers/mtd/nand/vf610_nfc.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index d275691dbb7c..8805d6325579 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c | |||
@@ -561,7 +561,6 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat, | |||
561 | u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS; | 561 | u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS; |
562 | u8 ecc_status; | 562 | u8 ecc_status; |
563 | u8 ecc_count; | 563 | u8 ecc_count; |
564 | int flips; | ||
565 | int flips_threshold = nfc->chip.ecc.strength / 2; | 564 | int flips_threshold = nfc->chip.ecc.strength / 2; |
566 | 565 | ||
567 | ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff; | 566 | ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff; |
@@ -578,16 +577,9 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat, | |||
578 | * On an erased page, bit count (including OOB) should be zero or | 577 | * On an erased page, bit count (including OOB) should be zero or |
579 | * at least less then half of the ECC strength. | 578 | * at least less then half of the ECC strength. |
580 | */ | 579 | */ |
581 | flips = count_written_bits(dat, nfc->chip.ecc.size, flips_threshold); | 580 | return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob, |
582 | flips += count_written_bits(oob, mtd->oobsize, flips_threshold); | 581 | mtd->oobsize, NULL, 0, |
583 | 582 | flips_threshold); | |
584 | if (unlikely(flips > flips_threshold)) | ||
585 | return -EINVAL; | ||
586 | |||
587 | /* Erased page. */ | ||
588 | memset(dat, 0xff, nfc->chip.ecc.size); | ||
589 | memset(oob, 0xff, mtd->oobsize); | ||
590 | return flips; | ||
591 | } | 583 | } |
592 | 584 | ||
593 | static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip, | 585 | static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip, |