aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/denali.c
diff options
context:
space:
mode:
authorMike Dunn <mikedunn@newsguy.com>2012-04-25 15:06:09 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-05-14 00:12:06 -0400
commit3f91e94f7f511de74c0d2abe08672ccdbdd1961c (patch)
treed33e95596bbebc824a1331c83951a25d2118fd36 /drivers/mtd/nand/denali.c
parentd062d4ede877fcd2ecc4c6262abad09a6f32950a (diff)
mtd: nand: read_page() returns max_bitflips
The ecc.read_page() method for nand drivers is changed to return the maximum number of bitflips that were corrected on any one region covering an ecc step, This patch doesn't change what the nand code returns to mtd. This v2 includes the change to the fsl_ifc_nand driver requested by Scott¹. ¹ http://lists.infradead.org/pipermail/linux-mtd/2012-April/040883.html Signed-off-by: Mike Dunn <mikedunn@newsguy.com> Acked-by (freescale changes): Scott Wood <scottwood@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/denali.c')
-rw-r--r--drivers/mtd/nand/denali.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index a1048c7c5d2c..1b346474dba8 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -924,9 +924,10 @@ bool is_erased(uint8_t *buf, int len)
924#define ECC_LAST_ERR(x) ((x) & ERR_CORRECTION_INFO__LAST_ERR_INFO) 924#define ECC_LAST_ERR(x) ((x) & ERR_CORRECTION_INFO__LAST_ERR_INFO)
925 925
926static bool handle_ecc(struct denali_nand_info *denali, uint8_t *buf, 926static bool handle_ecc(struct denali_nand_info *denali, uint8_t *buf,
927 uint32_t irq_status) 927 uint32_t irq_status, unsigned int *max_bitflips)
928{ 928{
929 bool check_erased_page = false; 929 bool check_erased_page = false;
930 unsigned int bitflips = 0;
930 931
931 if (irq_status & INTR_STATUS__ECC_ERR) { 932 if (irq_status & INTR_STATUS__ECC_ERR) {
932 /* read the ECC errors. we'll ignore them for now */ 933 /* read the ECC errors. we'll ignore them for now */
@@ -965,6 +966,7 @@ static bool handle_ecc(struct denali_nand_info *denali, uint8_t *buf,
965 /* correct the ECC error */ 966 /* correct the ECC error */
966 buf[offset] ^= err_correction_value; 967 buf[offset] ^= err_correction_value;
967 denali->mtd.ecc_stats.corrected++; 968 denali->mtd.ecc_stats.corrected++;
969 bitflips++;
968 } 970 }
969 } else { 971 } else {
970 /* if the error is not correctable, need to 972 /* if the error is not correctable, need to
@@ -984,6 +986,7 @@ static bool handle_ecc(struct denali_nand_info *denali, uint8_t *buf,
984 clear_interrupts(denali); 986 clear_interrupts(denali);
985 denali_set_intr_modes(denali, true); 987 denali_set_intr_modes(denali, true);
986 } 988 }
989 *max_bitflips = bitflips;
987 return check_erased_page; 990 return check_erased_page;
988} 991}
989 992
@@ -1121,6 +1124,7 @@ static int denali_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
1121static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip, 1124static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
1122 uint8_t *buf, int page) 1125 uint8_t *buf, int page)
1123{ 1126{
1127 unsigned int max_bitflips;
1124 struct denali_nand_info *denali = mtd_to_denali(mtd); 1128 struct denali_nand_info *denali = mtd_to_denali(mtd);
1125 1129
1126 dma_addr_t addr = denali->buf.dma_buf; 1130 dma_addr_t addr = denali->buf.dma_buf;
@@ -1153,7 +1157,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
1153 1157
1154 memcpy(buf, denali->buf.buf, mtd->writesize); 1158 memcpy(buf, denali->buf.buf, mtd->writesize);
1155 1159
1156 check_erased_page = handle_ecc(denali, buf, irq_status); 1160 check_erased_page = handle_ecc(denali, buf, irq_status, &max_bitflips);
1157 denali_enable_dma(denali, false); 1161 denali_enable_dma(denali, false);
1158 1162
1159 if (check_erased_page) { 1163 if (check_erased_page) {
@@ -1167,7 +1171,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
1167 denali->mtd.ecc_stats.failed++; 1171 denali->mtd.ecc_stats.failed++;
1168 } 1172 }
1169 } 1173 }
1170 return 0; 1174 return max_bitflips;
1171} 1175}
1172 1176
1173static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, 1177static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,