Commit 718e38b4 authored by Roger Quadros's avatar Roger Quadros Committed by Brian Norris

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: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent cc7fce80
...@@ -125,7 +125,8 @@ static int write_whole_device(void) ...@@ -125,7 +125,8 @@ static int write_whole_device(void)
* Display the address, offset and data bytes at comparison failure. * Display the address, offset and data bytes at comparison failure.
* Return number of bitflips encountered. * Return number of bitflips encountered.
*/ */
static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t count) static size_t memcmpshowoffset(loff_t addr, loff_t offset, const void *cs,
const void *ct, size_t count)
{ {
const unsigned char *su1, *su2; const unsigned char *su1, *su2;
int res; int res;
...@@ -135,8 +136,9 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou ...@@ -135,8 +136,9 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou
for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--, i++) { for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--, i++) {
res = *su1 ^ *su2; res = *su1 ^ *su2;
if (res) { if (res) {
pr_info("error @addr[0x%lx:0x%zx] 0x%x -> 0x%x diff 0x%x\n", pr_info("error @addr[0x%lx:0x%lx] 0x%x -> 0x%x diff 0x%x\n",
(unsigned long)addr, i, *su1, *su2, res); (unsigned long)addr, (unsigned long)offset + i,
*su1, *su2, res);
bitflips += hweight8(res); bitflips += hweight8(res);
} }
} }
...@@ -144,6 +146,9 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou ...@@ -144,6 +146,9 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou
return bitflips; return bitflips;
} }
#define memcmpshow(addr, cs, ct, count) memcmpshowoffset((addr), 0, (cs), (ct),\
(count))
/* /*
* Compare with 0xff and show the address, offset and data bytes at * Compare with 0xff and show the address, offset and data bytes at
* comparison failure. Return number of bitflips encountered. * comparison failure. Return number of bitflips encountered.
...@@ -228,9 +233,10 @@ static int verify_eraseblock(int ebnum) ...@@ -228,9 +233,10 @@ static int verify_eraseblock(int ebnum)
errcnt += 1; errcnt += 1;
return err ? err : -1; return err ? err : -1;
} }
bitflips = memcmpshow(addr, readbuf + use_offset, bitflips = memcmpshowoffset(addr, use_offset,
writebuf + (use_len_max * i) + use_offset, readbuf + use_offset,
use_len); writebuf + (use_len_max * i) + use_offset,
use_len);
/* verify pre-offset area for 0xff */ /* verify pre-offset area for 0xff */
bitflips += memffshow(addr, 0, readbuf, use_offset); bitflips += memffshow(addr, 0, readbuf, use_offset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment