diff options
author | Josh Wu <josh.wu@atmel.com> | 2012-06-25 06:07:45 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-07-06 13:17:07 -0400 |
commit | fdbad98dff8007f2b8bee6698b5d25ebba0471c9 (patch) | |
tree | 823d68f687ad90108ec6a4c53d17cb3bde1b3950 /drivers/mtd/nand/denali.c | |
parent | 3dfe41a4c705223c66373968327407e11c2fb1a1 (diff) |
mtd: nand: teach write_page and write_page_raw return an error code
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>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand/denali.c')
-rw-r--r-- | drivers/mtd/nand/denali.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 0650aafa0dd2..e706a237170f 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c | |||
@@ -1028,7 +1028,7 @@ static void denali_setup_dma(struct denali_nand_info *denali, int op) | |||
1028 | 1028 | ||
1029 | /* writes a page. user specifies type, and this function handles the | 1029 | /* writes a page. user specifies type, and this function handles the |
1030 | * configuration details. */ | 1030 | * configuration details. */ |
1031 | static void write_page(struct mtd_info *mtd, struct nand_chip *chip, | 1031 | static int write_page(struct mtd_info *mtd, struct nand_chip *chip, |
1032 | const uint8_t *buf, bool raw_xfer) | 1032 | const uint8_t *buf, bool raw_xfer) |
1033 | { | 1033 | { |
1034 | struct denali_nand_info *denali = mtd_to_denali(mtd); | 1034 | struct denali_nand_info *denali = mtd_to_denali(mtd); |
@@ -1078,6 +1078,8 @@ static void write_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
1078 | 1078 | ||
1079 | denali_enable_dma(denali, false); | 1079 | denali_enable_dma(denali, false); |
1080 | dma_sync_single_for_cpu(denali->dev, addr, size, DMA_TO_DEVICE); | 1080 | dma_sync_single_for_cpu(denali->dev, addr, size, DMA_TO_DEVICE); |
1081 | |||
1082 | return 0; | ||
1081 | } | 1083 | } |
1082 | 1084 | ||
1083 | /* NAND core entry points */ | 1085 | /* NAND core entry points */ |
@@ -1086,24 +1088,24 @@ static void write_page(struct mtd_info *mtd, struct nand_chip *chip, | |||
1086 | * writing a page with ECC or without is similar, all the work is done | 1088 | * writing a page with ECC or without is similar, all the work is done |
1087 | * by write_page above. | 1089 | * by write_page above. |
1088 | * */ | 1090 | * */ |
1089 | static void denali_write_page(struct mtd_info *mtd, struct nand_chip *chip, | 1091 | static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip, |
1090 | const uint8_t *buf, int oob_required) | 1092 | const uint8_t *buf, int oob_required) |
1091 | { | 1093 | { |
1092 | /* for regular page writes, we let HW handle all the ECC | 1094 | /* for regular page writes, we let HW handle all the ECC |
1093 | * data written to the device. */ | 1095 | * data written to the device. */ |
1094 | write_page(mtd, chip, buf, false); | 1096 | return write_page(mtd, chip, buf, false); |
1095 | } | 1097 | } |
1096 | 1098 | ||
1097 | /* This is the callback that the NAND core calls to write a page without ECC. | 1099 | /* This is the callback that the NAND core calls to write a page without ECC. |
1098 | * raw access is similar to ECC page writes, so all the work is done in the | 1100 | * raw access is similar to ECC page writes, so all the work is done in the |
1099 | * write_page() function above. | 1101 | * write_page() function above. |
1100 | */ | 1102 | */ |
1101 | static void denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, | 1103 | static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, |
1102 | const uint8_t *buf, int oob_required) | 1104 | const uint8_t *buf, int oob_required) |
1103 | { | 1105 | { |
1104 | /* for raw page writes, we want to disable ECC and simply write | 1106 | /* for raw page writes, we want to disable ECC and simply write |
1105 | whatever data is in the buffer. */ | 1107 | whatever data is in the buffer. */ |
1106 | write_page(mtd, chip, buf, true); | 1108 | return write_page(mtd, chip, buf, true); |
1107 | } | 1109 | } |
1108 | 1110 | ||
1109 | static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip, | 1111 | static int denali_write_oob(struct mtd_info *mtd, struct nand_chip *chip, |