aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorPekon Gupta <pekon@ti.com>2014-03-18 09:26:43 -0400
committerBrian Norris <computersforpeace@gmail.com>2014-03-20 04:47:59 -0400
commitde0a4d69e6758bfa5792e7c723a9220eb5be5a32 (patch)
tree9e3f5e1f0f3c03ac809f47eebe8ad04bbde4c8ae /drivers/mtd/nand
parent4e558072ef91f0ca681a74c3aef9d6a30c116f2a (diff)
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/nand')
-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,
1359{ 1359{
1360 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 1360 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
1361 mtd); 1361 mtd);
1362 struct nand_ecc_ctrl *ecc = &info->nand.ecc;
1362 int eccsteps = info->nand.ecc.steps; 1363 int eccsteps = info->nand.ecc.steps;
1363 int i , j, stat = 0; 1364 int i , j, stat = 0;
1364 int eccsize, eccflag, ecc_vector_size; 1365 int eccflag, actual_eccbytes;
1365 struct elm_errorvec err_vec[ERROR_VECTOR_MAX]; 1366 struct elm_errorvec err_vec[ERROR_VECTOR_MAX];
1366 u_char *ecc_vec = calc_ecc; 1367 u_char *ecc_vec = calc_ecc;
1367 u_char *spare_ecc = read_ecc; 1368 u_char *spare_ecc = read_ecc;
@@ -1369,6 +1370,20 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1369 enum bch_ecc type; 1370 enum bch_ecc type;
1370 bool is_error_reported = false; 1371 bool is_error_reported = false;
1371 1372
1373 switch (info->ecc_opt) {
1374 case OMAP_ECC_BCH4_CODE_HW:
1375 /* omit 7th ECC byte reserved for ROM code compatibility */
1376 actual_eccbytes = ecc->bytes - 1;
1377 break;
1378 case OMAP_ECC_BCH8_CODE_HW:
1379 /* omit 14th ECC byte reserved for ROM code compatibility */
1380 actual_eccbytes = ecc->bytes - 1;
1381 break;
1382 default:
1383 pr_err("invalid driver configuration\n");
1384 return -EINVAL;
1385 }
1386
1372 /* Initialize elm error vector to zero */ 1387 /* Initialize elm error vector to zero */
1373 memset(err_vec, 0, sizeof(err_vec)); 1388 memset(err_vec, 0, sizeof(err_vec));
1374 1389
@@ -1380,14 +1395,6 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1380 erased_ecc_vec = bch4_vector; 1395 erased_ecc_vec = bch4_vector;
1381 } 1396 }
1382 1397
1383 ecc_vector_size = info->nand.ecc.bytes;
1384
1385 /*
1386 * Remove extra byte padding for BCH8 RBL
1387 * compatibility and erased page handling
1388 */
1389 eccsize = ecc_vector_size - 1;
1390
1391 for (i = 0; i < eccsteps ; i++) { 1398 for (i = 0; i < eccsteps ; i++) {
1392 eccflag = 0; /* initialize eccflag */ 1399 eccflag = 0; /* initialize eccflag */
1393 1400
@@ -1395,8 +1402,7 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1395 * Check any error reported, 1402 * Check any error reported,
1396 * In case of error, non zero ecc reported. 1403 * In case of error, non zero ecc reported.
1397 */ 1404 */
1398 1405 for (j = 0; j < actual_eccbytes; j++) {
1399 for (j = 0; (j < eccsize); j++) {
1400 if (calc_ecc[j] != 0) { 1406 if (calc_ecc[j] != 0) {
1401 eccflag = 1; /* non zero ecc, error present */ 1407 eccflag = 1; /* non zero ecc, error present */
1402 break; 1408 break;
@@ -1421,7 +1427,7 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1421 * zeros are more than threshold erased page, either 1427 * zeros are more than threshold erased page, either
1422 * case page reported as uncorrectable. 1428 * case page reported as uncorrectable.
1423 */ 1429 */
1424 if (hweight8(~read_ecc[eccsize]) >= threshold) { 1430 if (hweight8(~read_ecc[actual_eccbytes]) >= threshold) {
1425 /* 1431 /*
1426 * Update elm error vector as 1432 * Update elm error vector as
1427 * data area is programmed 1433 * data area is programmed
@@ -1433,7 +1439,8 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1433 int bitflip_count; 1439 int bitflip_count;
1434 u_char *buf = &data[info->nand.ecc.size * i]; 1440 u_char *buf = &data[info->nand.ecc.size * i];
1435 1441
1436 if (memcmp(calc_ecc, erased_ecc_vec, eccsize)) { 1442 if (memcmp(calc_ecc, erased_ecc_vec,
1443 actual_eccbytes)) {
1437 bitflip_count = erased_sector_bitflips( 1444 bitflip_count = erased_sector_bitflips(
1438 buf, read_ecc, info); 1445 buf, read_ecc, info);
1439 1446
@@ -1446,8 +1453,8 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1446 } 1453 }
1447 1454
1448 /* Update the ecc vector */ 1455 /* Update the ecc vector */
1449 calc_ecc += ecc_vector_size; 1456 calc_ecc += ecc->bytes;
1450 read_ecc += ecc_vector_size; 1457 read_ecc += ecc->bytes;
1451 } 1458 }
1452 1459
1453 /* Check if any error reported */ 1460 /* Check if any error reported */
@@ -1496,7 +1503,7 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1496 1503
1497 /* Update page data with sector size */ 1504 /* Update page data with sector size */
1498 data += info->nand.ecc.size; 1505 data += info->nand.ecc.size;
1499 spare_ecc += ecc_vector_size; 1506 spare_ecc += ecc->bytes;
1500 } 1507 }
1501 1508
1502 for (i = 0; i < eccsteps; i++) 1509 for (i = 0; i < eccsteps; i++)