diff options
Diffstat (limited to 'patches.at91/0075-MTD-nand-add-return-value-for-write_page-write_page_.patch')
-rw-r--r-- | patches.at91/0075-MTD-nand-add-return-value-for-write_page-write_page_.patch | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/patches.at91/0075-MTD-nand-add-return-value-for-write_page-write_page_.patch b/patches.at91/0075-MTD-nand-add-return-value-for-write_page-write_page_.patch new file mode 100644 index 00000000000000..3078b197840136 --- /dev/null +++ b/patches.at91/0075-MTD-nand-add-return-value-for-write_page-write_page_.patch @@ -0,0 +1,155 @@ +From 8a6cf5507a3070841f8b4636af42d847d885f50d Mon Sep 17 00:00:00 2001 +From: Josh Wu <josh.wu@atmel.com> +Date: Mon, 25 Jun 2012 15:15:54 +0800 +Subject: MTD: nand: add return value for write_page()/write_page_raw() + functions in structure of nand_ecc_ctrl. + +Is the equivalent of commit fdbad98dff8007f2b8bee6698b5d25ebba0471c9 upstream. + +There is an implemention of hardware ECC write page function which may return an +error indication. +For instance, using Atmel HW PMECC to write one page into a nand flash, the hardware +engine will compute the BCH ecc code for this page. so we need read a the +status register to theck whether the ecc code is generated. +But we cannot assume the status register always can be ready, for example, +incorrect hardware configuration or hardware issue, in such case we need +write_page() to return a error code. + +Since the definition of 'write_page' function in struct nand_ecc_ctrl is 'void'. +So this patch will: + 1. add return 'int' value for 'write_page' function. + 2. to be consitent, add return 'int' value for 'write_page_raw' fuctions too. + 3. add code to test the return value, and if negative, indicate an + error happend when write page with ECC. + 4. fix the compile warning in all impacted nand flash driver. + +Note: I couldn't compile-test all of these easily, as some had ARCH dependencies. + +Signed-off-by: Josh Wu <josh.wu@atmel.com> +--- + drivers/mtd/nand/nand_base.c | 27 +++++++++++++++++++-------- + include/linux/mtd/nand.h | 4 ++-- + 2 files changed, 21 insertions(+), 10 deletions(-) + +--- a/drivers/mtd/nand/nand_base.c ++++ b/drivers/mtd/nand/nand_base.c +@@ -1922,11 +1922,13 @@ out: + * + * Not for syndrome calculating ECC controllers, which use a special oob layout. + */ +-static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, ++static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, + const uint8_t *buf) + { + chip->write_buf(mtd, buf, mtd->writesize); + chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); ++ ++ return 0; + } + + /** +@@ -1937,7 +1939,7 @@ static void nand_write_page_raw(struct m + * + * We need a special oob layout and handling even when ECC isn't checked. + */ +-static void nand_write_page_raw_syndrome(struct mtd_info *mtd, ++static int nand_write_page_raw_syndrome(struct mtd_info *mtd, + struct nand_chip *chip, + const uint8_t *buf) + { +@@ -1967,6 +1969,8 @@ static void nand_write_page_raw_syndrome + size = mtd->oobsize - (oob - chip->oob_poi); + if (size) + chip->write_buf(mtd, oob, size); ++ ++ return 0; + } + /** + * nand_write_page_swecc - [REPLACEABLE] software ECC based page write function +@@ -1974,7 +1978,7 @@ static void nand_write_page_raw_syndrome + * @chip: nand chip info structure + * @buf: data buffer + */ +-static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, ++static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, + const uint8_t *buf) + { + int i, eccsize = chip->ecc.size; +@@ -1991,7 +1995,7 @@ static void nand_write_page_swecc(struct + for (i = 0; i < chip->ecc.total; i++) + chip->oob_poi[eccpos[i]] = ecc_calc[i]; + +- chip->ecc.write_page_raw(mtd, chip, buf); ++ return chip->ecc.write_page_raw(mtd, chip, buf); + } + + /** +@@ -2000,7 +2004,7 @@ static void nand_write_page_swecc(struct + * @chip: nand chip info structure + * @buf: data buffer + */ +-static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, ++static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, + const uint8_t *buf) + { + int i, eccsize = chip->ecc.size; +@@ -2020,6 +2024,8 @@ static void nand_write_page_hwecc(struct + chip->oob_poi[eccpos[i]] = ecc_calc[i]; + + chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); ++ ++ return 0; + } + + /** +@@ -2031,7 +2037,7 @@ static void nand_write_page_hwecc(struct + * The hw generator calculates the error syndrome automatically. Therefore we + * need a special oob layout and handling. + */ +-static void nand_write_page_syndrome(struct mtd_info *mtd, ++static int nand_write_page_syndrome(struct mtd_info *mtd, + struct nand_chip *chip, const uint8_t *buf) + { + int i, eccsize = chip->ecc.size; +@@ -2064,6 +2070,8 @@ static void nand_write_page_syndrome(str + i = mtd->oobsize - (oob - chip->oob_poi); + if (i) + chip->write_buf(mtd, oob, i); ++ ++ return 0; + } + + /** +@@ -2083,9 +2091,12 @@ static int nand_write_page(struct mtd_in + chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); + + if (unlikely(raw)) +- chip->ecc.write_page_raw(mtd, chip, buf); ++ status = chip->ecc.write_page_raw(mtd, chip, buf); + else +- chip->ecc.write_page(mtd, chip, buf); ++ status = chip->ecc.write_page(mtd, chip, buf); ++ ++ if (status < 0) ++ return status; + + /* + * Cached progamming disabled for now. Not sure if it's worth the +--- a/include/linux/mtd/nand.h ++++ b/include/linux/mtd/nand.h +@@ -361,13 +361,13 @@ struct nand_ecc_ctrl { + uint8_t *calc_ecc); + int (*read_page_raw)(struct mtd_info *mtd, struct nand_chip *chip, + uint8_t *buf, int page); +- void (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip, ++ int (*write_page_raw)(struct mtd_info *mtd, struct nand_chip *chip, + const uint8_t *buf); + int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip, + uint8_t *buf, int page); + int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, + uint32_t offs, uint32_t len, uint8_t *buf); +- void (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, ++ int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip, + const uint8_t *buf); + int (*write_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip, + int page); |