summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorPekon Gupta <pekon@ti.com>2014-03-18 18:56:43 +0530
committerBrian Norris <computersforpeace@gmail.com>2014-03-20 01:47:59 -0700
commitde0a4d69e6758bfa5792e7c723a9220eb5be5a32 (patch)
tree9e3f5e1f0f3c03ac809f47eebe8ad04bbde4c8ae /drivers/mtd
parent4e558072ef91f0ca681a74c3aef9d6a30c116f2a (diff)
downloadlinux-de0a4d69e6758bfa5792e7c723a9220eb5be5a32.tar.gz
linux-de0a4d69e6758bfa5792e7c723a9220eb5be5a32.tar.bz2
linux-de0a4d69e6758bfa5792e7c723a9220eb5be5a32.zip
mtd: nand: omap: ecc.correct: omap_elm_correct_data: rename ambiguous variable 'eccsize' and 'ecc_vector_size'
renaming following variables as they cause confusion due to resemblence to another similar field in 'struct nand_ecc_ctrl' (nand_chip->ecc.size). renaming: ecc_vector_size --> ecc->bytes (info->nand.ecc.bytes) renaming: eccsize --> actual_eccbytes (info->nand.ecc.bytes - 1) for BCH4 and BCH8 Tested-by: Stefan Roese <sr@denx.de> Signed-off-by: Pekon Gupta <pekon@ti.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/omap2.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 403afa71bbf3..4bf2f76d7d28 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1359,9 +1359,10 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
{
struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
mtd);
+ struct nand_ecc_ctrl *ecc = &info->nand.ecc;
int eccsteps = info->nand.ecc.steps;
int i , j, stat = 0;
- int eccsize, eccflag, ecc_vector_size;
+ int eccflag, actual_eccbytes;
struct elm_errorvec err_vec[ERROR_VECTOR_MAX];
u_char *ecc_vec = calc_ecc;
u_char *spare_ecc = read_ecc;
@@ -1369,6 +1370,20 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
enum bch_ecc type;
bool is_error_reported = false;
+ switch (info->ecc_opt) {
+ case OMAP_ECC_BCH4_CODE_HW:
+ /* omit 7th ECC byte reserved for ROM code compatibility */
+ actual_eccbytes = ecc->bytes - 1;
+ break;
+ case OMAP_ECC_BCH8_CODE_HW:
+ /* omit 14th ECC byte reserved for ROM code compatibility */
+ actual_eccbytes = ecc->bytes - 1;
+ break;
+ default:
+ pr_err("invalid driver configuration\n");
+ return -EINVAL;
+ }
+
/* Initialize elm error vector to zero */
memset(err_vec, 0, sizeof(err_vec));
@@ -1380,14 +1395,6 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
erased_ecc_vec = bch4_vector;
}
- ecc_vector_size = info->nand.ecc.bytes;
-
- /*
- * Remove extra byte padding for BCH8 RBL
- * compatibility and erased page handling
- */
- eccsize = ecc_vector_size - 1;
-
for (i = 0; i < eccsteps ; i++) {
eccflag = 0; /* initialize eccflag */
@@ -1395,8 +1402,7 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
* Check any error reported,
* In case of error, non zero ecc reported.
*/
-
- for (j = 0; (j < eccsize); j++) {
+ for (j = 0; j < actual_eccbytes; j++) {
if (calc_ecc[j] != 0) {
eccflag = 1; /* non zero ecc, error present */
break;
@@ -1421,7 +1427,7 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
* zeros are more than threshold erased page, either
* case page reported as uncorrectable.
*/
- if (hweight8(~read_ecc[eccsize]) >= threshold) {
+ if (hweight8(~read_ecc[actual_eccbytes]) >= threshold) {
/*
* Update elm error vector as
* data area is programmed
@@ -1433,7 +1439,8 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
int bitflip_count;
u_char *buf = &data[info->nand.ecc.size * i];
- if (memcmp(calc_ecc, erased_ecc_vec, eccsize)) {
+ if (memcmp(calc_ecc, erased_ecc_vec,
+ actual_eccbytes)) {
bitflip_count = erased_sector_bitflips(
buf, read_ecc, info);
@@ -1446,8 +1453,8 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
}
/* Update the ecc vector */
- calc_ecc += ecc_vector_size;
- read_ecc += ecc_vector_size;
+ calc_ecc += ecc->bytes;
+ read_ecc += ecc->bytes;
}
/* Check if any error reported */
@@ -1496,7 +1503,7 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
/* Update page data with sector size */
data += info->nand.ecc.size;
- spare_ecc += ecc_vector_size;
+ spare_ecc += ecc->bytes;
}
for (i = 0; i < eccsteps; i++)