Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1216972
| From | Stefan Agner <stefan@agner.ch> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v11 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support |
| Date | 2015-09-01 19:00 +0200 |
| Message-ID | <q3X4D-3Wm-31@gated-at.bofh.it> (permalink) |
| References | <q2fS2-3R7-7@gated-at.bofh.it> <q2fS2-3R7-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 2015-08-27 17:34, Stefan Agner wrote:
> +static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
> + uint8_t *oob, int page)
> +{
> + struct vf610_nfc *nfc = mtd_to_nfc(mtd);
> + 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;
> + ecc_count = ecc_status & ECC_STATUS_ERR_COUNT;
> +
> + if (!(ecc_status & ECC_STATUS_MASK))
> + return ecc_count;
> +
> + /* Read OOB without ECC unit enabled */
> + vf610_nfc_command(mtd, NAND_CMD_READOOB, 0, page);
> + vf610_nfc_read_buf(mtd, oob, mtd->oobsize);
> +
> + /*
> + * 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 0;
I guess I should return the amount of bitflips here. Will send out a v12
today.
--
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v11 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support Stefan Agner <stefan@agner.ch> - 2015-08-28 02:40 +0200 Re: [PATCH v11 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support Stefan Agner <stefan@agner.ch> - 2015-09-01 19:00 +0200
csiph-web