diff options
Diffstat (limited to 'drivers/mtd/nand/nand_ecc.c')
-rw-r--r-- | drivers/mtd/nand/nand_ecc.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c index 92320a643275..271b8e735e8f 100644 --- a/drivers/mtd/nand/nand_ecc.c +++ b/drivers/mtd/nand/nand_ecc.c | |||
@@ -150,20 +150,19 @@ static const char addressbits[256] = { | |||
150 | }; | 150 | }; |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte | 153 | * __nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte |
154 | * block | 154 | * block |
155 | * @mtd: MTD block structure | ||
156 | * @buf: input buffer with raw data | 155 | * @buf: input buffer with raw data |
156 | * @eccsize: data bytes per ecc step (256 or 512) | ||
157 | * @code: output buffer with ECC | 157 | * @code: output buffer with ECC |
158 | */ | 158 | */ |
159 | int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, | 159 | void __nand_calculate_ecc(const unsigned char *buf, unsigned int eccsize, |
160 | unsigned char *code) | 160 | unsigned char *code) |
161 | { | 161 | { |
162 | int i; | 162 | int i; |
163 | const uint32_t *bp = (uint32_t *)buf; | 163 | const uint32_t *bp = (uint32_t *)buf; |
164 | /* 256 or 512 bytes/ecc */ | 164 | /* 256 or 512 bytes/ecc */ |
165 | const uint32_t eccsize_mult = | 165 | const uint32_t eccsize_mult = eccsize >> 8; |
166 | (((struct nand_chip *)mtd->priv)->ecc.size) >> 8; | ||
167 | uint32_t cur; /* current value in buffer */ | 166 | uint32_t cur; /* current value in buffer */ |
168 | /* rp0..rp15..rp17 are the various accumulated parities (per byte) */ | 167 | /* rp0..rp15..rp17 are the various accumulated parities (per byte) */ |
169 | uint32_t rp0, rp1, rp2, rp3, rp4, rp5, rp6, rp7; | 168 | uint32_t rp0, rp1, rp2, rp3, rp4, rp5, rp6, rp7; |
@@ -412,6 +411,22 @@ int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, | |||
412 | (invparity[par & 0x55] << 2) | | 411 | (invparity[par & 0x55] << 2) | |
413 | (invparity[rp17] << 1) | | 412 | (invparity[rp17] << 1) | |
414 | (invparity[rp16] << 0); | 413 | (invparity[rp16] << 0); |
414 | } | ||
415 | EXPORT_SYMBOL(__nand_calculate_ecc); | ||
416 | |||
417 | /** | ||
418 | * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte | ||
419 | * block | ||
420 | * @mtd: MTD block structure | ||
421 | * @buf: input buffer with raw data | ||
422 | * @code: output buffer with ECC | ||
423 | */ | ||
424 | int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, | ||
425 | unsigned char *code) | ||
426 | { | ||
427 | __nand_calculate_ecc(buf, | ||
428 | ((struct nand_chip *)mtd->priv)->ecc.size, code); | ||
429 | |||
415 | return 0; | 430 | return 0; |
416 | } | 431 | } |
417 | EXPORT_SYMBOL(nand_calculate_ecc); | 432 | EXPORT_SYMBOL(nand_calculate_ecc); |