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


Groups > linux.kernel > #1351770

[PATCH 05/16] mtd: nand: export default read/write oob functions

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH 05/16] mtd: nand: export default read/write oob functions
Date 2016-03-07 17:30 +0100
Message-ID <ra6cH-5dM-35@gated-at.bofh.it> (permalink)
References <ra630-57L-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Export the default read/write oob functions (for the standard and syndrome
scheme), so that drivers can use them for their raw implementation and
implement their own functions for the normal oob operation.

This is required if your ECC engine is capable of fixing some of the OOB
data. In this case you have to overload the ->read_oob() and ->write_oob(),
but if you don't specify the ->read/write_oob_raw() functions they are
assigned to the ->read/write_oob() implementation, which is not what you
want.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/nand/nand_base.c | 18 ++++++++++--------
 include/linux/mtd/nand.h     | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index f2c8ff3..b8cfeb7 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1924,13 +1924,13 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
  * @chip: nand chip info structure
  * @page: page number to read
  */
-static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
-			     int page)
+int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
 {
 	chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
 	chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
 	return 0;
 }
+EXPORT_SYMBOL(nand_read_oob_std);
 
 /**
  * nand_read_oob_syndrome - [REPLACEABLE] OOB data read function for HW ECC
@@ -1939,8 +1939,8 @@ static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
  * @chip: nand chip info structure
  * @page: page number to read
  */
-static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
-				  int page)
+int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+			   int page)
 {
 	int length = mtd->oobsize;
 	int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
@@ -1968,6 +1968,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
 
 	return 0;
 }
+EXPORT_SYMBOL(nand_read_oob_syndrome);
 
 /**
  * nand_write_oob_std - [REPLACEABLE] the most common OOB data write function
@@ -1975,8 +1976,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
  * @chip: nand chip info structure
  * @page: page number to write
  */
-static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
-			      int page)
+int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
 {
 	int status = 0;
 	const uint8_t *buf = chip->oob_poi;
@@ -1991,6 +1991,7 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
 
 	return status & NAND_STATUS_FAIL ? -EIO : 0;
 }
+EXPORT_SYMBOL(nand_write_oob_std);
 
 /**
  * nand_write_oob_syndrome - [REPLACEABLE] OOB data write function for HW ECC
@@ -1999,8 +2000,8 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
  * @chip: nand chip info structure
  * @page: page number to write
  */
-static int nand_write_oob_syndrome(struct mtd_info *mtd,
-				   struct nand_chip *chip, int page)
+int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+			    int page)
 {
 	int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
 	int eccsize = chip->ecc.size, length = mtd->oobsize;
@@ -2050,6 +2051,7 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,
 
 	return status & NAND_STATUS_FAIL ? -EIO : 0;
 }
+EXPORT_SYMBOL(nand_write_oob_syndrome);
 
 /**
  * nand_do_read_oob - [INTERN] NAND read out-of-band
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 7604f4b..19b2f7d 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -1070,4 +1070,18 @@ int nand_check_erased_ecc_chunk(void *data, int datalen,
 				void *ecc, int ecclen,
 				void *extraoob, int extraooblen,
 				int threshold);
+
+/* Default write_oob implementation */
+int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page);
+
+/* Default write_oob syndrome implementation */
+int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+			    int page);
+
+/* Default read_oob implementation */
+int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page);
+
+/* Default read_oob syndrome implementation */
+int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
+			   int page);
 #endif /* __LINUX_MTD_NAND_H */
-- 
2.1.4

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


Thread

[PATCH 00/16] mtd: nand: sunxi: various improvements/fixes Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:20 +0100
  [PATCH 03/16] mtd: nand: sunxi: fix EDO mode selection Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:20 +0100
  [PATCH 12/16] mtd: nand: sunxi: disable clks on device removal Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
  [PATCH 14/16] mtd: nand: sunxi: fix ->dev_ready() implementation Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
  [PATCH 09/16] mtd: nand: sunxi: let the NAND controller control the CE line Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
  [PATCH 16/16] mtd: nand: sunxi: poll for events instead of using interrupts Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
  [PATCH 07/16] mtd: nand: sunxi: implement ->read_subpage() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
  [PATCH 10/16] mtd: nand: sunxi: fix the NFC_ECC_ERR_CNT() macro Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
    [PATCH 13/16] mtd: nand: enable ECC pipelining Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
    [PATCH 11/16] mtd: nand: sunxi: fix NFC_CTL setting Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
    [PATCH 15/16] mtd: nand: sunxi: make use of readl_poll_timeout() Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
  [PATCH 05/16] mtd: nand: export default read/write oob functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100
  [PATCH 08/16] mtd: nand: sunxi: improve ->cmd_ctrl() function Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-03-07 17:30 +0100

csiph-web