mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: computersforpeace@gmail.com
Cc: sebastian@breakpoint.cc, robh+dt@kernel.org, pawel.moll@arm.com,
	mark.rutland@arm.com, ijc+devicetree@hellion.org.uk,
	galak@codeaurora.org, shawn.guo@linaro.org,
	kernel@pengutronix.de, boris.brezillon@free-electrons.com,
	marb@ixxat.de, aaron@tastycactus.com, bpringlemeir@gmail.com,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, albert.aribaud@3adev.fr,
	klimov.linux@gmail.com, Bill Pringlemeir <bpringlemeir@nbsps.com>
Subject: Re: [PATCH v11 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
Date: Tue, 01 Sep 2015 09:55:48 -0700	[thread overview]
Message-ID: <575f176ee9d5e6d785ed2352887d5336@agner.ch> (raw)
In-Reply-To: <1440722100-25388-3-git-send-email-stefan@agner.ch>

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

  reply	other threads:[~2015-09-01 16:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-28  0:34 [PATCH v11 0/5] mtd: nand: vf610_nfc: Freescale NFC for VF610 Stefan Agner
2015-08-28  0:34 ` [PATCH v11 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others Stefan Agner
2015-08-28  0:34 ` [PATCH v11 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support Stefan Agner
2015-09-01 16:55   ` Stefan Agner [this message]
2015-08-28  0:34 ` [PATCH v11 3/5] mtd: nand: vf610_nfc: add device tree bindings Stefan Agner
2015-08-28  0:34 ` [PATCH v11 4/5] ARM: dts: vf610twr: add NAND flash controller peripherial Stefan Agner
2015-08-28  0:35 ` [PATCH v11 5/5] ARM: dts: vf-colibri: enable NAND flash controller Stefan Agner

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=575f176ee9d5e6d785ed2352887d5336@agner.ch \
    --to=stefan@agner.ch \
    --cc=aaron@tastycactus.com \
    --cc=albert.aribaud@3adev.fr \
    --cc=boris.brezillon@free-electrons.com \
    --cc=bpringlemeir@gmail.com \
    --cc=bpringlemeir@nbsps.com \
    --cc=computersforpeace@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=klimov.linux@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marb@ixxat.de \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sebastian@breakpoint.cc \
    --cc=shawn.guo@linaro.org \
    /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

all inboxes | Powered by JetHome®