diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2009-09-04 12:20:44 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-09-19 17:20:33 -0400 |
commit | 0f777fb9318739baf517c4f4ef66347d8898643d (patch) | |
tree | cba8a2f7e78d364561e23e21c93c7f287a87fab3 /drivers/mtd | |
parent | be2f092bfc4f6a415bb4c3e2dcbf521a1f2a0fe5 (diff) |
mtd: nand: fix tmio_nand ecc correction
This driver may be reading 512 bytes at a times, but still calculates
256-byte sector ECC. So the nand_correct_data() is not appropriate
for this driver. Implement its ecc.correct function calling
__nand_correct_data() twice.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Acked-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/tmio_nand.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c index daa6a4c3b8ce..92c73344a669 100644 --- a/drivers/mtd/nand/tmio_nand.c +++ b/drivers/mtd/nand/tmio_nand.c | |||
@@ -301,6 +301,21 @@ static int tmio_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | |||
301 | return 0; | 301 | return 0; |
302 | } | 302 | } |
303 | 303 | ||
304 | static int tmio_nand_correct_data(struct mtd_info *mtd, unsigned char *buf, | ||
305 | unsigned char *read_ecc, unsigned char *calc_ecc) | ||
306 | { | ||
307 | int r0, r1; | ||
308 | |||
309 | /* assume ecc.size = 512 and ecc.bytes = 6 */ | ||
310 | r0 = __nand_correct_data(buf, read_ecc, calc_ecc, 256); | ||
311 | if (r0 < 0) | ||
312 | return r0; | ||
313 | r1 = __nand_correct_data(buf + 256, read_ecc + 3, calc_ecc + 3, 256); | ||
314 | if (r1 < 0) | ||
315 | return r1; | ||
316 | return r0 + r1; | ||
317 | } | ||
318 | |||
304 | static int tmio_hw_init(struct platform_device *dev, struct tmio_nand *tmio) | 319 | static int tmio_hw_init(struct platform_device *dev, struct tmio_nand *tmio) |
305 | { | 320 | { |
306 | struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; | 321 | struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; |
@@ -424,7 +439,7 @@ static int tmio_probe(struct platform_device *dev) | |||
424 | nand_chip->ecc.bytes = 6; | 439 | nand_chip->ecc.bytes = 6; |
425 | nand_chip->ecc.hwctl = tmio_nand_enable_hwecc; | 440 | nand_chip->ecc.hwctl = tmio_nand_enable_hwecc; |
426 | nand_chip->ecc.calculate = tmio_nand_calculate_ecc; | 441 | nand_chip->ecc.calculate = tmio_nand_calculate_ecc; |
427 | nand_chip->ecc.correct = nand_correct_data; | 442 | nand_chip->ecc.correct = tmio_nand_correct_data; |
428 | 443 | ||
429 | if (data) | 444 | if (data) |
430 | nand_chip->badblock_pattern = data->badblock_pattern; | 445 | nand_chip->badblock_pattern = data->badblock_pattern; |