diff options
Diffstat (limited to 'drivers/mtd/nand/mtk_ecc.c')
-rw-r--r-- | drivers/mtd/nand/mtk_ecc.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/mtd/nand/mtk_ecc.c b/drivers/mtd/nand/mtk_ecc.c index d54f666417e1..dbf256217b3e 100644 --- a/drivers/mtd/nand/mtk_ecc.c +++ b/drivers/mtd/nand/mtk_ecc.c | |||
@@ -86,6 +86,8 @@ struct mtk_ecc { | |||
86 | struct completion done; | 86 | struct completion done; |
87 | struct mutex lock; | 87 | struct mutex lock; |
88 | u32 sectors; | 88 | u32 sectors; |
89 | |||
90 | u8 eccdata[112]; | ||
89 | }; | 91 | }; |
90 | 92 | ||
91 | static inline void mtk_ecc_wait_idle(struct mtk_ecc *ecc, | 93 | static inline void mtk_ecc_wait_idle(struct mtk_ecc *ecc, |
@@ -366,9 +368,8 @@ int mtk_ecc_encode(struct mtk_ecc *ecc, struct mtk_ecc_config *config, | |||
366 | u8 *data, u32 bytes) | 368 | u8 *data, u32 bytes) |
367 | { | 369 | { |
368 | dma_addr_t addr; | 370 | dma_addr_t addr; |
369 | u8 *p; | 371 | u32 len; |
370 | u32 len, i, val; | 372 | int ret; |
371 | int ret = 0; | ||
372 | 373 | ||
373 | addr = dma_map_single(ecc->dev, data, bytes, DMA_TO_DEVICE); | 374 | addr = dma_map_single(ecc->dev, data, bytes, DMA_TO_DEVICE); |
374 | ret = dma_mapping_error(ecc->dev, addr); | 375 | ret = dma_mapping_error(ecc->dev, addr); |
@@ -393,14 +394,12 @@ int mtk_ecc_encode(struct mtk_ecc *ecc, struct mtk_ecc_config *config, | |||
393 | 394 | ||
394 | /* Program ECC bytes to OOB: per sector oob = FDM + ECC + SPARE */ | 395 | /* Program ECC bytes to OOB: per sector oob = FDM + ECC + SPARE */ |
395 | len = (config->strength * ECC_PARITY_BITS + 7) >> 3; | 396 | len = (config->strength * ECC_PARITY_BITS + 7) >> 3; |
396 | p = data + bytes; | ||
397 | 397 | ||
398 | /* write the parity bytes generated by the ECC back to the OOB region */ | 398 | /* write the parity bytes generated by the ECC back to temp buffer */ |
399 | for (i = 0; i < len; i++) { | 399 | __ioread32_copy(ecc->eccdata, ecc->regs + ECC_ENCPAR(0), round_up(len, 4)); |
400 | if ((i % 4) == 0) | 400 | |
401 | val = readl(ecc->regs + ECC_ENCPAR(i / 4)); | 401 | /* copy into possibly unaligned OOB region with actual length */ |
402 | p[i] = (val >> ((i % 4) * 8)) & 0xff; | 402 | memcpy(data + bytes, ecc->eccdata, len); |
403 | } | ||
404 | timeout: | 403 | timeout: |
405 | 404 | ||
406 | dma_unmap_single(ecc->dev, addr, bytes, DMA_TO_DEVICE); | 405 | dma_unmap_single(ecc->dev, addr, bytes, DMA_TO_DEVICE); |