diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2012-09-07 12:48:08 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-09-29 10:47:45 -0400 |
commit | ccaa67956cfef80776d72d134467235f0055c863 (patch) | |
tree | 37093c6dea3eb216018482314f4120d0599d6217 /drivers | |
parent | 6060fb42a0bf93015d05c1a857b94894936f40ee (diff) |
mtd: mtd_nandecctest: add no corruption test
This adds no corruptin test case listed below:
Prepare data block and ECC data with no corruption, and verify that
the data block is preserved by __nand_correct_data()
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/tests/mtd_nandecctest.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/mtd/tests/mtd_nandecctest.c b/drivers/mtd/tests/mtd_nandecctest.c index 204f796ed3e7..ff97b1070235 100644 --- a/drivers/mtd/tests/mtd_nandecctest.c +++ b/drivers/mtd/tests/mtd_nandecctest.c | |||
@@ -48,6 +48,27 @@ static void single_bit_error_data(void *error_data, void *correct_data, | |||
48 | __change_bit_le(offset, error_data); | 48 | __change_bit_le(offset, error_data); |
49 | } | 49 | } |
50 | 50 | ||
51 | static void no_bit_error(void *error_data, void *error_ecc, | ||
52 | void *correct_data, void *correct_ecc, const size_t size) | ||
53 | { | ||
54 | memcpy(error_data, correct_data, size); | ||
55 | memcpy(error_ecc, correct_ecc, 3); | ||
56 | } | ||
57 | |||
58 | static int no_bit_error_verify(void *error_data, void *error_ecc, | ||
59 | void *correct_data, const size_t size) | ||
60 | { | ||
61 | unsigned char calc_ecc[3]; | ||
62 | int ret; | ||
63 | |||
64 | __nand_calculate_ecc(error_data, size, calc_ecc); | ||
65 | ret = __nand_correct_data(error_data, error_ecc, calc_ecc, size); | ||
66 | if (ret == 0 && !memcmp(correct_data, error_data, size)) | ||
67 | return 0; | ||
68 | |||
69 | return -EINVAL; | ||
70 | } | ||
71 | |||
51 | static void single_bit_error_in_data(void *error_data, void *error_ecc, | 72 | static void single_bit_error_in_data(void *error_data, void *error_ecc, |
52 | void *correct_data, void *correct_ecc, const size_t size) | 73 | void *correct_data, void *correct_ecc, const size_t size) |
53 | { | 74 | { |
@@ -71,6 +92,11 @@ static int single_bit_error_correct(void *error_data, void *error_ecc, | |||
71 | 92 | ||
72 | static const struct nand_ecc_test nand_ecc_test[] = { | 93 | static const struct nand_ecc_test nand_ecc_test[] = { |
73 | { | 94 | { |
95 | .name = "no-bit-error", | ||
96 | .prepare = no_bit_error, | ||
97 | .verify = no_bit_error_verify, | ||
98 | }, | ||
99 | { | ||
74 | .name = "single-bit-error-in-data-correct", | 100 | .name = "single-bit-error-in-data-correct", |
75 | .prepare = single_bit_error_in_data, | 101 | .prepare = single_bit_error_in_data, |
76 | .verify = single_bit_error_correct, | 102 | .verify = single_bit_error_correct, |