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


Groups > linux.kernel > #1286023

[PATCH 21/23] staging: mt29f_spinand: switch to mtd_ooblayout_ops

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH 21/23] staging: mt29f_spinand: switch to mtd_ooblayout_ops
Date 2015-12-07 23:30 +0100
Message-ID <qDcsa-2fH-11@gated-at.bofh.it> (permalink)
References <qDcs9-2fH-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 44 ++++++++++++++++-----------
 1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index cb9d5ab..967d50a 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -42,23 +42,29 @@ static inline struct spinand_state *mtd_to_state(struct mtd_info *mtd)
 static int enable_hw_ecc;
 static int enable_read_hw_ecc;
 
-static struct nand_ecclayout spinand_oob_64 = {
-	.eccbytes = 24,
-	.eccpos = {
-		1, 2, 3, 4, 5, 6,
-		17, 18, 19, 20, 21, 22,
-		33, 34, 35, 36, 37, 38,
-		49, 50, 51, 52, 53, 54, },
-	.oobfree = {
-		{.offset = 8,
-			.length = 8},
-		{.offset = 24,
-			.length = 8},
-		{.offset = 40,
-			.length = 8},
-		{.offset = 56,
-			.length = 8},
-	}
+static int spinand_oob_64_eccpos(struct mtd_info *mtd, int eccbyte)
+{
+	if (eccbyte > 23)
+		return -ERANGE;
+
+	return ((eccbyte / 6) * 16) + 1;
+}
+
+static int spinand_oob_64_oobfree(struct mtd_info *mtd, int section,
+				  struct nand_oobfree *oobfree)
+{
+	if (section > 3)
+		return -ERANGE;
+
+	oobfree->offset = (section * 16) + 8;
+	oobfree->length = 8;
+
+	return 0;
+}
+
+const struct mtd_ooblayout_ops spinand_oob_64_ops = {
+	.eccpos = spinand_oob_64_eccpos,
+	.oobfree = spinand_oob_64_oobfree,
 };
 #endif
 
@@ -883,7 +889,6 @@ static int spinand_probe(struct spi_device *spi_nand)
 
 	chip->ecc.strength = 1;
 	chip->ecc.total	= chip->ecc.steps * chip->ecc.bytes;
-	chip->ecc.layout = &spinand_oob_64;
 	chip->ecc.read_page = spinand_read_page_hwecc;
 	chip->ecc.write_page = spinand_write_page_hwecc;
 #else
@@ -911,6 +916,9 @@ static int spinand_probe(struct spi_device *spi_nand)
 	mtd->priv = chip;
 	mtd->dev.parent = &spi_nand->dev;
 	mtd->oobsize = 64;
+#ifdef CONFIG_MTD_SPINAND_ONDIEECC
+	mtd_set_ooblayout(mtd, &spinand_oob_64_ops);
+#endif
 
 	if (nand_scan(mtd, 1))
 		return -ENXIO;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH 00/23] mtd: rework ECC layout definition Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 15/23] mtd: create an mtd_ooblayout_ops struct to ease ECC layout definition Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 21/23] staging: mt29f_spinand: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
    Re: [linux-sunxi] [PATCH 21/23] staging: mt29f_spinand: switch to mtd_ooblayout_ops Julian Calaby <julian.calaby@gmail.com> - 2015-12-08 01:10 +0100
      Re: [linux-sunxi] [PATCH 21/23] staging: mt29f_spinand: switch to  mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-08 09:50 +0100
  [PATCH 03/23] mtd: nftl: kill unused oobinfo field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 20/23] mtd: onenand: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 01/23] mtd: kill the ecclayout->oobavail field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
    Re: [linux-sunxi] [PATCH 01/23] mtd: kill the ecclayout->oobavail  field Priit Laes <plaes@plaes.org> - 2015-12-08 07:50 +0100
      Re: [linux-sunxi] [PATCH 01/23] mtd: kill the ecclayout->oobavail  field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-08 09:20 +0100
  [PATCH 23/23] mtd: kill the nand_ecclayout struct Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 12/23] mtd: use mtd_eccpos() and mtd_oobfree() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
    Re: [PATCH 12/23] mtd: use mtd_eccpos() and mtd_oobfree() where  appropriate kbuild test robot <lkp@intel.com> - 2015-12-08 00:40 +0100
  [PATCH 11/23] mtd: add mtd_eccpos(), mtd_oobfree() and mtd_eccbytes() helper functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 22/23] mtd: nand: kill layout field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 18/23] mtd: nand: bch: switch to nand_ecclayout_pos Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 07/23] staging: mt29f_spinand: kill unused ecclayout field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
  [PATCH 09/23] mtd: nand: vf610: remove useless mtd->ecclayout assignment Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:30 +0100
    Re: [PATCH 09/23] mtd: nand: vf610: remove useless mtd->ecclayout  assignment Stefan Agner <stefan@agner.ch> - 2015-12-07 23:50 +0100
  [PATCH 10/23] mtd: nand: simplify nand_bch_init() usage Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  [PATCH 17/23] mtd: nand: implement the default mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  [PATCH 06/23] mtd: nand: kill unused ->ecclayout field in platform_nand_chip struct Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  [PATCH 08/23] mtd: nand: lpc32xx_mlc: fix ecc.size Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  [PATCH 05/23] mtd: nand: jz4770: kill the ->ecc_layout field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
    Re: [PATCH 05/23] mtd: nand: jz4770: kill the ->ecc_layout field Harvey Hunt <harvey.hunt@imgtec.com> - 2015-12-08 11:40 +0100
      Re: [PATCH 05/23] mtd: nand: jz4770: kill the ->ecc_layout field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-08 11:40 +0100
  [PATCH 04/23] mtd: nand: s3c2410: kill the ->ecc_layout field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
    Re: [PATCH 04/23] mtd: nand: s3c2410: kill the ->ecc_layout field Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2015-12-08 01:40 +0100
  [PATCH 13/23] mtd: add mtd_set_ecclayout() helper function Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  [PATCH 02/23] mtd: inftl: kill unused oobinfo field Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  [PATCH 16/23] mtd: docg3: switch to mtd_ooblayout_ops Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  [PATCH 14/23] mtd: use mtd_set_ecclayout() where appropriate Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-12-07 23:40 +0100
  Re: [PATCH 19/23] mtd: nand: switch all drivers to mtd_ooblayout_ops Ralf Baechle <ralf@linux-mips.org> - 2015-12-08 11:20 +0100

csiph-web