Skip to content

Commit 9d02fc2

Browse files
author
Boris Brezillon
committed
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: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent 5abcd95 commit 9d02fc2

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,13 +1893,13 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
18931893
* @chip: nand chip info structure
18941894
* @page: page number to read
18951895
*/
1896-
static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
1897-
int page)
1896+
int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
18981897
{
18991898
chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);
19001899
chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
19011900
return 0;
19021901
}
1902+
EXPORT_SYMBOL(nand_read_oob_std);
19031903

19041904
/**
19051905
* nand_read_oob_syndrome - [REPLACEABLE] OOB data read function for HW ECC
@@ -1908,8 +1908,8 @@ static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
19081908
* @chip: nand chip info structure
19091909
* @page: page number to read
19101910
*/
1911-
static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1912-
int page)
1911+
int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1912+
int page)
19131913
{
19141914
int length = mtd->oobsize;
19151915
int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
@@ -1937,15 +1937,15 @@ static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
19371937

19381938
return 0;
19391939
}
1940+
EXPORT_SYMBOL(nand_read_oob_syndrome);
19401941

19411942
/**
19421943
* nand_write_oob_std - [REPLACEABLE] the most common OOB data write function
19431944
* @mtd: mtd info structure
19441945
* @chip: nand chip info structure
19451946
* @page: page number to write
19461947
*/
1947-
static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
1948-
int page)
1948+
int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page)
19491949
{
19501950
int status = 0;
19511951
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,
19601960

19611961
return status & NAND_STATUS_FAIL ? -EIO : 0;
19621962
}
1963+
EXPORT_SYMBOL(nand_write_oob_std);
19631964

19641965
/**
19651966
* 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,
19681969
* @chip: nand chip info structure
19691970
* @page: page number to write
19701971
*/
1971-
static int nand_write_oob_syndrome(struct mtd_info *mtd,
1972-
struct nand_chip *chip, int page)
1972+
int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1973+
int page)
19731974
{
19741975
int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
19751976
int eccsize = chip->ecc.size, length = mtd->oobsize;
@@ -2019,6 +2020,7 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,
20192020

20202021
return status & NAND_STATUS_FAIL ? -EIO : 0;
20212022
}
2023+
EXPORT_SYMBOL(nand_write_oob_syndrome);
20222024

20232025
/**
20242026
* nand_do_read_oob - [INTERN] NAND read out-of-band

‎include/linux/mtd/nand.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,4 +1078,18 @@ int nand_check_erased_ecc_chunk(void *data, int datalen,
10781078
void *ecc, int ecclen,
10791079
void *extraoob, int extraooblen,
10801080
int threshold);
1081+
1082+
/* Default write_oob implementation */
1083+
int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page);
1084+
1085+
/* Default write_oob syndrome implementation */
1086+
int nand_write_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1087+
int page);
1088+
1089+
/* Default read_oob implementation */
1090+
int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, int page);
1091+
1092+
/* Default read_oob syndrome implementation */
1093+
int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
1094+
int page);
10811095
#endif /* __LINUX_MTD_NAND_H */

0 commit comments

Comments
 (0)