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


Groups > linux.kernel > #1326566

[PATCH v2 32/51] mtd: nand: docg4: switch to mtd_ooblayout_ops

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH v2 32/51] mtd: nand: docg4: switch to mtd_ooblayout_ops
Date 2016-02-04 11:20 +0100
Message-ID <qYpb4-7ep-17@gated-at.bofh.it> (permalink)
References <qYp1n-7ay-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Implementing the mtd_ooblayout_ops interface is the new way of exposing
ECC/OOB layout to MTD users.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/nand/docg4.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index fb46fd7..f5ca9a5 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -222,10 +222,33 @@ struct docg4_priv {
  * Bytes 8 - 14 are hw-generated ecc covering entire page + oob bytes 0 - 14.
  * Byte 15 (the last) is used by the driver as a "page written" flag.
  */
-static struct nand_ecclayout docg4_oobinfo = {
-	.eccbytes = 9,
-	.eccpos = {7, 8, 9, 10, 11, 12, 13, 14, 15},
-	.oobfree = { {.offset = 2, .length = 5} }
+static int docg4_ooblayout_ecc(struct mtd_info *mtd, int section,
+			       struct mtd_oob_region *oobregion)
+{
+	if (section)
+		return -ERANGE;
+
+	oobregion->offset = 7;
+	oobregion->length = 9;
+
+	return 0;
+}
+
+static int docg4_ooblayout_free(struct mtd_info *mtd, int section,
+				struct mtd_oob_region *oobregion)
+{
+	if (section)
+		return -ERANGE;
+
+	oobregion->offset = 2;
+	oobregion->length = 5;
+
+	return 0;
+}
+
+static const struct mtd_ooblayout_ops docg4_ooblayout_ops = {
+	.ecc = docg4_ooblayout_ecc,
+	.free = docg4_ooblayout_free,
 };
 
 /*
@@ -1209,6 +1232,7 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
 	mtd->writesize = DOCG4_PAGE_SIZE;
 	mtd->erasesize = DOCG4_BLOCK_SIZE;
 	mtd->oobsize = DOCG4_OOB_SIZE;
+	mtd_set_ooblayout(mtd, &docg4_ooblayout_ops);
 	nand->chipsize = DOCG4_CHIP_SIZE;
 	nand->chip_shift = DOCG4_CHIP_SHIFT;
 	nand->bbt_erase_shift = nand->phys_erase_shift = DOCG4_ERASE_SHIFT;
@@ -1217,7 +1241,6 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
 	nand->pagemask = 0x3ffff;
 	nand->badblockpos = NAND_LARGE_BADBLOCK_POS;
 	nand->badblockbits = 8;
-	nand->ecc.layout = &docg4_oobinfo;
 	nand->ecc.mode = NAND_ECC_HW_SYNDROME;
 	nand->ecc.size = DOCG4_PAGE_SIZE;
 	nand->ecc.prepad = 8;
-- 
2.1.4

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


Thread

[PATCH v2 00/51] mtd: rework ECC layout definition Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:10 +0100
  [PATCH v2 17/51] mtd: onenand: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:10 +0100
  [PATCH v2 48/51] mtd: onenand: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:10 +0100
  [PATCH v2 49/51] staging: mt29f_spinand: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:10 +0100
  [PATCH v2 34/51] mtd: nand: fsl_ifc: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 29/51] mtd: nand: davinci: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 26/51] mtd: nand: bf5xx: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 31/51] mtd: nand: diskonchip: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 32/51] mtd: nand: docg4: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 24/51] mtd: nand: jz4740: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 38/51] mtd: nand: jz4780: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 40/51] mtd: nand: mxc: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 35/51] mtd: nand: fsmc: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 47/51] mtd: nand: vf610: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 46/51] mtd: nand: sunxi: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 23/51] mtd: nand: sharpsl: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 50/51] mtd: nand: kill the ecc->layout field Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 39/51] mtd: nand: lpc32xx: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 30/51] mtd: nand: denali: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 33/51] mtd: nand: fsl_elbc: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 44/51] mtd: nand: sh_flctl: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 42/51] mtd: nand: pxa3xx: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 36/51] mtd: nand: gpmi: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 41/51] mtd: nand: omap2: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:20 +0100
  [PATCH v2 25/51] mtd: nand: atmel: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 19/51] mtd: create an mtd_ooblayout_ops struct to ease ECC layout definition Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 02/51] mtd: create an mtd_oobavail() helper and make use of it Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 01/51] mtd: kill the ecclayout->oobavail field Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 28/51] mtd: nand: cafe: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 05/51] mtd: add mtd_ooblayout_xxx() helper functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
    Re: [PATCH v2 05/51] mtd: add mtd_ooblayout_xxx() helper functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-05 08:40 +0100
    Re: [PATCH v2 05/51] mtd: add mtd_ooblayout_xxx() helper functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-05 10:30 +0100
  [PATCH v2 15/51] mtd: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 08/51] mtd: nand: atmel: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 18/51] mtd: docg3: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
    Re: [PATCH v2 18/51] mtd: docg3: use mtd_set_ecclayout() where appropriate Robert Jarzmik <robert.jarzmik@free.fr> - 2016-02-06 23:00 +0100
  [PATCH v2 14/51] mtd: add mtd_set_ecclayout() helper function Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 27/51] mtd: nand: brcm: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 10/51] mtd: nand: gpmi: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 13/51] mtd: onenand: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 16/51] mtd: nand: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 21/51] mtd: nand: implement the default mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 12/51] mtd: nand: omap2: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 11/51] mtd: nand: lpc32xx: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 22/51] mtd: nand: bch: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:30 +0100
  [PATCH v2 04/51] mtd: nand: simplify nand_bch_init() usage Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:40 +0100
  [PATCH v2 03/51] mtd: mtdswap: remove useless if (!mtd->ecclayout) test Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:40 +0100
  [PATCH v2 06/51] mtd: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:40 +0100
  [PATCH v2 07/51] mtd: nand: core: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:40 +0100
    Re: [PATCH v2 07/51] mtd: nand: core: use mtd_ooblayout_xxx()  helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-05 10:40 +0100
  [PATCH v2 09/51] mtd: nand: fsl_ifc: use mtd_ooblayout_xxx() helpers where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-02-04 11:40 +0100

csiph-web