Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347215
b: refs/heads/master
c: c0c70d9
h: refs/heads/master
i:
  347213: adaaa59
  347211: 8947898
  347207: 43dd018
  347199: de0d94a
v: v3
  • Loading branch information
Josh Wu authored and Artem Bityutskiy committed Dec 3, 2012
1 parent 1b2faa0 commit d1c6daf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 070c32223ae8a724a190ea769104ea41567e3673
refs/heads/master: c0c70d9ee6569150ff6a10f9d3c50c63c917e3a1
16 changes: 11 additions & 5 deletions trunk/drivers/mtd/nand/atmel_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
struct atmel_nand_host *host = nand_chip->priv;
int i, err_nbr, eccbytes;
uint8_t *buf_pos;
int total_err = 0;

eccbytes = nand_chip->ecc.bytes;
for (i = 0; i < eccbytes; i++)
Expand Down Expand Up @@ -750,12 +751,13 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
pmecc_correct_data(mtd, buf_pos, ecc, i,
host->pmecc_bytes_per_sector, err_nbr);
mtd->ecc_stats.corrected += err_nbr;
total_err += err_nbr;
}
}
pmecc_stat >>= 1;
}

return 0;
return total_err;
}

static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
Expand All @@ -767,6 +769,7 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
uint32_t *eccpos = chip->ecc.layout->eccpos;
uint32_t stat;
unsigned long end_time;
int bitflips = 0;

pmecc_writel(host->ecc, CTRL, PMECC_CTRL_RST);
pmecc_writel(host->ecc, CTRL, PMECC_CTRL_DISABLE);
Expand All @@ -789,11 +792,14 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,
}

stat = pmecc_readl_relaxed(host->ecc, ISR);
if (stat != 0)
if (pmecc_correction(mtd, stat, buf, &oob[eccpos[0]]) != 0)
return -EIO;
if (stat != 0) {
bitflips = pmecc_correction(mtd, stat, buf, &oob[eccpos[0]]);
if (bitflips < 0)
/* uncorrectable errors */
return 0;
}

return 0;
return bitflips;
}

static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
Expand Down

0 comments on commit d1c6daf

Please sign in to comment.