aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-02-03 14:12:19 -0500
committerBoris Brezillon <boris.brezillon@free-electrons.com>2016-04-19 16:05:51 -0400
commit8cfc1e8b68f3e0b144f17a94709c757c6db05b82 (patch)
treec1f953e34173b0493cbdaf3564b1a907bef6d4bd /drivers/mtd
parentb9c0f65feab8a6dd4f37fdd8150cf5fe716304f5 (diff)
mtd: nand: omap2: use mtd_ooblayout_xxx() helpers where appropriate
The mtd_ooblayout_xxx() helper functions have been added to avoid direct accesses to the ecclayout field, and thus ease for future reworks. Use these helpers in all places where the oobfree[] and eccpos[] arrays where directly accessed. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/omap2.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index c59bc85009d7..38fe6b8a0b14 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1498,9 +1498,8 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
1498static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip, 1498static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
1499 const uint8_t *buf, int oob_required, int page) 1499 const uint8_t *buf, int oob_required, int page)
1500{ 1500{
1501 int i; 1501 int ret;
1502 uint8_t *ecc_calc = chip->buffers->ecccalc; 1502 uint8_t *ecc_calc = chip->buffers->ecccalc;
1503 uint32_t *eccpos = chip->ecc.layout->eccpos;
1504 1503
1505 /* Enable GPMC ecc engine */ 1504 /* Enable GPMC ecc engine */
1506 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); 1505 chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
@@ -1511,8 +1510,10 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
1511 /* Update ecc vector from GPMC result registers */ 1510 /* Update ecc vector from GPMC result registers */
1512 chip->ecc.calculate(mtd, buf, &ecc_calc[0]); 1511 chip->ecc.calculate(mtd, buf, &ecc_calc[0]);
1513 1512
1514 for (i = 0; i < chip->ecc.total; i++) 1513 ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
1515 chip->oob_poi[eccpos[i]] = ecc_calc[i]; 1514 chip->ecc.total);
1515 if (ret)
1516 return ret;
1516 1517
1517 /* Write ecc vector to OOB area */ 1518 /* Write ecc vector to OOB area */
1518 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); 1519 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -1539,10 +1540,7 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
1539{ 1540{
1540 uint8_t *ecc_calc = chip->buffers->ecccalc; 1541 uint8_t *ecc_calc = chip->buffers->ecccalc;
1541 uint8_t *ecc_code = chip->buffers->ecccode; 1542 uint8_t *ecc_code = chip->buffers->ecccode;
1542 uint32_t *eccpos = chip->ecc.layout->eccpos; 1543 int stat, ret;
1543 uint8_t *oob = &chip->oob_poi[eccpos[0]];
1544 uint32_t oob_pos = mtd->writesize + chip->ecc.layout->eccpos[0];
1545 int stat;
1546 unsigned int max_bitflips = 0; 1544 unsigned int max_bitflips = 0;
1547 1545
1548 /* Enable GPMC ecc engine */ 1546 /* Enable GPMC ecc engine */
@@ -1552,13 +1550,18 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
1552 chip->read_buf(mtd, buf, mtd->writesize); 1550 chip->read_buf(mtd, buf, mtd->writesize);
1553 1551
1554 /* Read oob bytes */ 1552 /* Read oob bytes */
1555 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, -1); 1553 chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
1556 chip->read_buf(mtd, oob, chip->ecc.total); 1554 mtd->writesize + BADBLOCK_MARKER_LENGTH, -1);
1555 chip->read_buf(mtd, chip->oob_poi + BADBLOCK_MARKER_LENGTH,
1556 chip->ecc.total);
1557 1557
1558 /* Calculate ecc bytes */ 1558 /* Calculate ecc bytes */
1559 chip->ecc.calculate(mtd, buf, ecc_calc); 1559 chip->ecc.calculate(mtd, buf, ecc_calc);
1560 1560
1561 memcpy(ecc_code, &chip->oob_poi[eccpos[0]], chip->ecc.total); 1561 ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
1562 chip->ecc.total);
1563 if (ret)
1564 return ret;
1562 1565
1563 stat = chip->ecc.correct(mtd, buf, ecc_code, ecc_calc); 1566 stat = chip->ecc.correct(mtd, buf, ecc_code, ecc_calc);
1564 1567