diff options
author | Roger Quadros <rogerq@ti.com> | 2015-07-08 07:50:19 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2015-08-27 19:30:01 -0400 |
commit | 718e38b4d96085b4dab08d3d32e5e033aa1ba6e9 (patch) | |
tree | 9f8519b8d96a1e306159c95a23e0d01ea9a76c45 | |
parent | cc7fce80229067890365c1ee196be5d304d36dea (diff) |
mtd: mtd_oobtest: Fix the address offset with vary_offset case
When vary_offset is set (e.g. test case 3), the offset is not always
zero so memcmpshow() will show the wrong offset in the print message.
To fix this we introduce a new function memcmpshowoffset() which takes
offset as a parameter and displays the right offset and use it in
the case where offset is non zero.
The old memcmpshow() functionality is preserved by converting it into
a macro with offset preset to 0.
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r-- | drivers/mtd/tests/oobtest.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c index 8e8525f0202f..31762120eb56 100644 --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c | |||
@@ -125,7 +125,8 @@ static int write_whole_device(void) | |||
125 | * Display the address, offset and data bytes at comparison failure. | 125 | * Display the address, offset and data bytes at comparison failure. |
126 | * Return number of bitflips encountered. | 126 | * Return number of bitflips encountered. |
127 | */ | 127 | */ |
128 | static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t count) | 128 | static size_t memcmpshowoffset(loff_t addr, loff_t offset, const void *cs, |
129 | const void *ct, size_t count) | ||
129 | { | 130 | { |
130 | const unsigned char *su1, *su2; | 131 | const unsigned char *su1, *su2; |
131 | int res; | 132 | int res; |
@@ -135,8 +136,9 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou | |||
135 | for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--, i++) { | 136 | for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--, i++) { |
136 | res = *su1 ^ *su2; | 137 | res = *su1 ^ *su2; |
137 | if (res) { | 138 | if (res) { |
138 | pr_info("error @addr[0x%lx:0x%zx] 0x%x -> 0x%x diff 0x%x\n", | 139 | pr_info("error @addr[0x%lx:0x%lx] 0x%x -> 0x%x diff 0x%x\n", |
139 | (unsigned long)addr, i, *su1, *su2, res); | 140 | (unsigned long)addr, (unsigned long)offset + i, |
141 | *su1, *su2, res); | ||
140 | bitflips += hweight8(res); | 142 | bitflips += hweight8(res); |
141 | } | 143 | } |
142 | } | 144 | } |
@@ -144,6 +146,9 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou | |||
144 | return bitflips; | 146 | return bitflips; |
145 | } | 147 | } |
146 | 148 | ||
149 | #define memcmpshow(addr, cs, ct, count) memcmpshowoffset((addr), 0, (cs), (ct),\ | ||
150 | (count)) | ||
151 | |||
147 | /* | 152 | /* |
148 | * Compare with 0xff and show the address, offset and data bytes at | 153 | * Compare with 0xff and show the address, offset and data bytes at |
149 | * comparison failure. Return number of bitflips encountered. | 154 | * comparison failure. Return number of bitflips encountered. |
@@ -228,9 +233,10 @@ static int verify_eraseblock(int ebnum) | |||
228 | errcnt += 1; | 233 | errcnt += 1; |
229 | return err ? err : -1; | 234 | return err ? err : -1; |
230 | } | 235 | } |
231 | bitflips = memcmpshow(addr, readbuf + use_offset, | 236 | bitflips = memcmpshowoffset(addr, use_offset, |
232 | writebuf + (use_len_max * i) + use_offset, | 237 | readbuf + use_offset, |
233 | use_len); | 238 | writebuf + (use_len_max * i) + use_offset, |
239 | use_len); | ||
234 | 240 | ||
235 | /* verify pre-offset area for 0xff */ | 241 | /* verify pre-offset area for 0xff */ |
236 | bitflips += memffshow(addr, 0, readbuf, use_offset); | 242 | bitflips += memffshow(addr, 0, readbuf, use_offset); |