aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/atmel_nand.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/atmel_nand.c')
-rw-r--r--drivers/mtd/nand/atmel_nand.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 2165576a1c67..97ac6712bb19 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -324,9 +324,10 @@ static int atmel_nand_calculate(struct mtd_info *mtd,
324 * mtd: mtd info structure 324 * mtd: mtd info structure
325 * chip: nand chip info structure 325 * chip: nand chip info structure
326 * buf: buffer to store read data 326 * buf: buffer to store read data
327 * oob_required: caller expects OOB data read to chip->oob_poi
327 */ 328 */
328static int atmel_nand_read_page(struct mtd_info *mtd, 329static int atmel_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
329 struct nand_chip *chip, uint8_t *buf, int page) 330 uint8_t *buf, int oob_required, int page)
330{ 331{
331 int eccsize = chip->ecc.size; 332 int eccsize = chip->ecc.size;
332 int eccbytes = chip->ecc.bytes; 333 int eccbytes = chip->ecc.bytes;
@@ -335,6 +336,7 @@ static int atmel_nand_read_page(struct mtd_info *mtd,
335 uint8_t *oob = chip->oob_poi; 336 uint8_t *oob = chip->oob_poi;
336 uint8_t *ecc_pos; 337 uint8_t *ecc_pos;
337 int stat; 338 int stat;
339 unsigned int max_bitflips = 0;
338 340
339 /* 341 /*
340 * Errata: ALE is incorrectly wired up to the ECC controller 342 * Errata: ALE is incorrectly wired up to the ECC controller
@@ -371,10 +373,12 @@ static int atmel_nand_read_page(struct mtd_info *mtd,
371 /* check if there's an error */ 373 /* check if there's an error */
372 stat = chip->ecc.correct(mtd, p, oob, NULL); 374 stat = chip->ecc.correct(mtd, p, oob, NULL);
373 375
374 if (stat < 0) 376 if (stat < 0) {
375 mtd->ecc_stats.failed++; 377 mtd->ecc_stats.failed++;
376 else 378 } else {
377 mtd->ecc_stats.corrected += stat; 379 mtd->ecc_stats.corrected += stat;
380 max_bitflips = max_t(unsigned int, max_bitflips, stat);
381 }
378 382
379 /* get back to oob start (end of page) */ 383 /* get back to oob start (end of page) */
380 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); 384 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
@@ -382,7 +386,7 @@ static int atmel_nand_read_page(struct mtd_info *mtd,
382 /* read the oob */ 386 /* read the oob */
383 chip->read_buf(mtd, oob, mtd->oobsize); 387 chip->read_buf(mtd, oob, mtd->oobsize);
384 388
385 return 0; 389 return max_bitflips;
386} 390}
387 391
388/* 392/*