Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1367398

[PATCH v5 08/50] mtd: nand: omap2: use mtd_ooblayout_xxx() helpers where appropriate

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH v5 08/50] mtd: nand: omap2: use mtd_ooblayout_xxx() helpers where appropriate
Date 2016-03-30 18:40 +0200
Message-ID <rirk0-87s-53@gated-at.bofh.it> (permalink)
References <rir0C-7XM-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/mtd/nand/omap2.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 0749ca1..4ebf16b 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1495,9 +1495,8 @@ static int omap_elm_correct_data(struct mtd_info *mtd, u_char *data,
 static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
 			       const uint8_t *buf, int oob_required, int page)
 {
-	int i;
+	int ret;
 	uint8_t *ecc_calc = chip->buffers->ecccalc;
-	uint32_t *eccpos = chip->ecc.layout->eccpos;
 
 	/* Enable GPMC ecc engine */
 	chip->ecc.hwctl(mtd, NAND_ECC_WRITE);
@@ -1508,8 +1507,10 @@ static int omap_write_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
 	/* Update ecc vector from GPMC result registers */
 	chip->ecc.calculate(mtd, buf, &ecc_calc[0]);
 
-	for (i = 0; i < chip->ecc.total; i++)
-		chip->oob_poi[eccpos[i]] = ecc_calc[i];
+	ret = mtd_ooblayout_set_eccbytes(mtd, ecc_calc, chip->oob_poi, 0,
+					 chip->ecc.total);
+	if (ret)
+		return ret;
 
 	/* Write ecc vector to OOB area */
 	chip->write_buf(mtd, chip->oob_poi, mtd->oobsize);
@@ -1536,10 +1537,7 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
 {
 	uint8_t *ecc_calc = chip->buffers->ecccalc;
 	uint8_t *ecc_code = chip->buffers->ecccode;
-	uint32_t *eccpos = chip->ecc.layout->eccpos;
-	uint8_t *oob = &chip->oob_poi[eccpos[0]];
-	uint32_t oob_pos = mtd->writesize + chip->ecc.layout->eccpos[0];
-	int stat;
+	int stat, ret;
 	unsigned int max_bitflips = 0;
 
 	/* Enable GPMC ecc engine */
@@ -1549,13 +1547,16 @@ static int omap_read_page_bch(struct mtd_info *mtd, struct nand_chip *chip,
 	chip->read_buf(mtd, buf, mtd->writesize);
 
 	/* Read oob bytes */
-	chip->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_pos, -1);
-	chip->read_buf(mtd, oob, chip->ecc.total);
+	chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1);
+	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
 
 	/* Calculate ecc bytes */
 	chip->ecc.calculate(mtd, buf, ecc_calc);
 
-	memcpy(ecc_code, &chip->oob_poi[eccpos[0]], chip->ecc.total);
+	ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
+					 chip->ecc.total);
+	if (ret)
+		return ret;
 
 	stat = chip->ecc.correct(mtd, buf, ecc_code, ecc_calc);
 
-- 
2.5.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 00/52] mtd: rework ECC layout definition Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 07/50] mtd: nand: lpc32xx: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 18/50] mtd: nand: implement the default mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 03/50] mtd: nand: core: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 13/50] mtd: nand: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 34/50] mtd: nand: gpmi: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 01/50] mtd: add mtd_ooblayout_xxx() helper functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 27/50] mtd: nand: denali: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 21/50] mtd: nand: jz4740: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
    Re: [PATCH v5 21/50] mtd: nand: jz4740: switch to mtd_ooblayout_ops Lars-Peter Clausen <lars@metafoo.de> - 2016-03-30 21:50 +0200
  [PATCH v5 08/50] mtd: nand: omap2: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 12/50] mtd: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 10/50] mtd: onenand: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 17/50] mtd: docg3: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 11/50] mtd: add mtd_set_ecclayout() helper function Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 14/50] mtd: onenand: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 06/50] mtd: nand: gpmi: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 19/50] mtd: nand: bch: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 26/50] mtd: nand: davinci: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 09/50] mtd: nand: qcom: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200
  [PATCH v5 24/50] mtd: nand: brcm: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-30 18:40 +0200

csiph-web