diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2009-10-22 03:53:32 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-11-30 04:32:19 -0500 |
commit | 1c63aca32903efc219fb9df72bae5344f3e54ed5 (patch) | |
tree | f3731478a5b163344e55bdf03eef25895d03cdab /drivers/mtd/nand | |
parent | 3cf602532c535ec655725e9833378e04c9fd7783 (diff) |
mtd: Add __nand_calculate_ecc() to NAND ECC functions
Add __nand_calculate_ecc() which does not take struct mtd_info.
The built-in 256/512 software ECC calculation and correction tester
will use it.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand')
-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 db7ae9d6a296..809fb53304ae 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); |