Commit 9d02fc2a authored by Boris Brezillon's avatar Boris Brezillon

mtd: nand: export default read/write oob functions

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: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 5abcd95d
...@@ -1893,13 +1893,13 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -1893,13 +1893,13 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
* @chip: nand chip info structure * @chip: nand chip info structure
* @page: page number to read * @page: page number to read
*/ */
static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
int page)
{ {
chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
return 0; return 0;
} }
EXPORT_SYMBOL(nand_read_oob_std);
/** /**
* nand_read_oob_syndrome - [REPLACEABLE] OOB data read function for HW ECC * nand_read_oob_syndrome - [REPLACEABLE] OOB data read function for HW ECC
...@@ -1908,7 +1908,7 @@ static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1908,7 +1908,7 @@ static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
* @chip: nand chip info structure * @chip: nand chip info structure
* @page: page number to read * @page: page number to read
*/ */
static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
int page) int page)
{ {
int length = mtd->oobsize; int length = mtd->oobsize;
...@@ -1937,6 +1937,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1937,6 +1937,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
return 0; return 0;
} }
EXPORT_SYMBOL(nand_read_oob_syndrome);
/** /**
* nand_write_oob_std - [REPLACEABLE] the most common OOB data write function * nand_write_oob_std - [REPLACEABLE] the most common OOB data write function
...@@ -1944,8 +1945,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1944,8 +1945,7 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
* @chip: nand chip info structure * @chip: nand chip info structure
* @page: page number to write * @page: page number to write
*/ */
static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
int page)
{ {
int status = 0; int status = 0;
const uint8_t *buf = chip->oob_poi; const uint8_t *buf = chip->oob_poi;
...@@ -1960,6 +1960,7 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1960,6 +1960,7 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
return status & NAND_STATUS_FAIL ? -EIO : 0; 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 * nand_write_oob_syndrome - [REPLACEABLE] OOB data write function for HW ECC
...@@ -1968,8 +1969,8 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -1968,8 +1969,8 @@ static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
* @chip: nand chip info structure * @chip: nand chip info structure
* @page: page number to write * @page: page number to write
*/ */
static int nand_write_oob_syndrome(struct mtd_info *mtd, int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
struct nand_chip *chip, int page) int page)
{ {
int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
int eccsize = chip->ecc.size, length = mtd->oobsize; int eccsize = chip->ecc.size, length = mtd->oobsize;
...@@ -2019,6 +2020,7 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd, ...@@ -2019,6 +2020,7 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,
return status & NAND_STATUS_FAIL ? -EIO : 0; return status & NAND_STATUS_FAIL ? -EIO : 0;
} }
EXPORT_SYMBOL(nand_write_oob_syndrome);
/** /**
* nand_do_read_oob - [INTERN] NAND read out-of-band * nand_do_read_oob - [INTERN] NAND read out-of-band
......
...@@ -1078,4 +1078,18 @@ int nand_check_erased_ecc_chunk(void *data, int datalen, ...@@ -1078,4 +1078,18 @@ int nand_check_erased_ecc_chunk(void *data, int datalen,
void *ecc, int ecclen, void *ecc, int ecclen,
void *extraoob, int extraooblen, void *extraoob, int extraooblen,
int threshold); 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 */ #endif /* __LINUX_MTD_NAND_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment