Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1367389
| From | Boris Brezillon <boris.brezillon@free-electrons.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v5 07/50] mtd: nand: lpc32xx: use mtd_ooblayout_xxx() helpers where appropriate |
| Date | 2016-03-30 18:40 +0200 |
| Message-ID | <rirjZ-87s-27@gated-at.bofh.it> (permalink) |
| References | <rir0C-7XM-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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/lpc32xx_slc.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
index 3b8f373..10cf8e62 100644
--- a/drivers/mtd/nand/lpc32xx_slc.c
+++ b/drivers/mtd/nand/lpc32xx_slc.c
@@ -604,7 +604,8 @@ static int lpc32xx_nand_read_page_syndrome(struct mtd_info *mtd,
int oob_required, int page)
{
struct lpc32xx_nand_host *host = nand_get_controller_data(chip);
- int stat, i, status;
+ struct mtd_oob_region oobregion = { };
+ int stat, i, status, error;
uint8_t *oobecc, tmpecc[LPC32XX_ECC_SAVE_SIZE];
/* Issue read command */
@@ -620,7 +621,11 @@ static int lpc32xx_nand_read_page_syndrome(struct mtd_info *mtd,
lpc32xx_slc_ecc_copy(tmpecc, (uint32_t *) host->ecc_buf, chip->ecc.steps);
/* Pointer to ECC data retrieved from NAND spare area */
- oobecc = chip->oob_poi + chip->ecc.layout->eccpos[0];
+ error = mtd_ooblayout_ecc(mtd, 0, &oobregion);
+ if (error)
+ return error;
+
+ oobecc = chip->oob_poi + oobregion.offset;
for (i = 0; i < chip->ecc.steps; i++) {
stat = chip->ecc.correct(mtd, buf, oobecc,
@@ -666,7 +671,8 @@ static int lpc32xx_nand_write_page_syndrome(struct mtd_info *mtd,
int oob_required, int page)
{
struct lpc32xx_nand_host *host = nand_get_controller_data(chip);
- uint8_t *pb = chip->oob_poi + chip->ecc.layout->eccpos[0];
+ struct mtd_oob_region oobregion = { };
+ uint8_t *pb;
int error;
/* Write data, calculate ECC on outbound data */
@@ -678,6 +684,11 @@ static int lpc32xx_nand_write_page_syndrome(struct mtd_info *mtd,
* The calculated ECC needs some manual work done to it before
* committing it to NAND. Process the calculated ECC and place
* the resultant values directly into the OOB buffer. */
+ error = mtd_ooblayout_ecc(mtd, 0, &oobregion);
+ if (error)
+ return error;
+
+ pb = chip->oob_poi + oobregion.offset;
lpc32xx_slc_ecc_copy(pb, (uint32_t *)host->ecc_buf, chip->ecc.steps);
/* Write ECC data to device */
--
2.5.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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