summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Schefter <steve@scheftech.com>2011-12-09 11:00:58 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-01-02 12:44:55 +0100
commit28f0de6e5f4929fbe5a8b7b6ff5746e4df77dde5 (patch)
treed0ee518669f45382ac98ce853c306af608f694e1
parent0c5310075b5e1995bba0ddeed5a674a075fdb8b0 (diff)
downloadbarebox-28f0de6e5f4929fbe5a8b7b6ff5746e4df77dde5.tar.gz
barebox-28f0de6e5f4929fbe5a8b7b6ff5746e4df77dde5.tar.xz
nand_omap_bch_decoder: Fix up error detection
Bit errors in the ECC itself are not beeing taken into account. In this cases the number of detected errors != number of corrected errors and chien search returns an error. This patch adds detection of bit errors in the ECC. Signed-off-by: Steve Schefter <steve@scheftech.com> Signed-off-by: Teresa Gámez <t.gamez@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/mtd/nand/nand_omap_bch_decoder.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/mtd/nand/nand_omap_bch_decoder.c b/drivers/mtd/nand/nand_omap_bch_decoder.c
index 356f71f0cd..d1455e4876 100644
--- a/drivers/mtd/nand/nand_omap_bch_decoder.c
+++ b/drivers/mtd/nand/nand_omap_bch_decoder.c
@@ -64,6 +64,7 @@ static int chien(unsigned int select_4_8, int err_nums,
unsigned int err[], unsigned int *location)
{
int i, count; /* Number of dectected errors */
+ int errorsinecc; /* Number of detected errors in ECC bits */
/* Contains accumulation of evaluation at x^i (i:1->8) */
unsigned int gammas[8] = {0};
unsigned int alpha;
@@ -77,7 +78,8 @@ static int chien(unsigned int select_4_8, int err_nums,
gammas[i] = err[i];
count = 0;
- for (i = 1; (i <= nn) && (count < err_nums); i++) {
+ errorsinecc = 0;
+ for (i = 1; (i <= nn) && ((count + errorsinecc) < err_nums); i++) {
/* Result of evaluation at root */
elp_sum = 1 ^ gammas[0] ^ gammas[1] ^
@@ -108,11 +110,13 @@ static int chien(unsigned int select_4_8, int err_nums,
if (i >= 2 * ecc_bits)
location[count++] =
kk_shorten - (bit - 2 * ecc_bits) - 1;
+ else
+ errorsinecc++;
}
}
/* Failure: No. of detected errors != No. or corrected errors */
- if (count != err_nums) {
+ if ((count + errorsinecc) != err_nums) {
count = -1;
printk(KERN_ERR "BCH decoding failed\n");
}