Skip to content

Commit 718e38b

Browse files
Roger Quadroscomputersforpeace
authored andcommitted
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>
1 parent cc7fce8 commit 718e38b

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎drivers/mtd/tests/oobtest.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ static int write_whole_device(void)
125125
* Display the address, offset and data bytes at comparison failure.
126126
* Return number of bitflips encountered.
127127
*/
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)
129130
{
130131
const unsigned char *su1, *su2;
131132
int res;
@@ -135,15 +136,19 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou
135136
for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--, i++) {
136137
res = *su1 ^ *su2;
137138
if (res) {
138-
pr_info("error @addr[0x%lx:0x%zx] 0x%x -> 0x%x diff 0x%x\n",
139-
(unsigned long)addr, i, *su1, *su2, res);
139+
pr_info("error @addr[0x%lx:0x%lx] 0x%x -> 0x%x diff 0x%x\n",
140+
(unsigned long)addr, (unsigned long)offset + i,
141+
*su1, *su2, res);
140142
bitflips += hweight8(res);
141143
}
142144
}
143145

144146
return bitflips;
145147
}
146148

149+
#define memcmpshow(addr, cs, ct, count) memcmpshowoffset((addr), 0, (cs), (ct),\
150+
(count))
151+
147152
/*
148153
* Compare with 0xff and show the address, offset and data bytes at
149154
* comparison failure. Return number of bitflips encountered.
@@ -228,9 +233,10 @@ static int verify_eraseblock(int ebnum)
228233
errcnt += 1;
229234
return err ? err : -1;
230235
}
231-
bitflips = memcmpshow(addr, readbuf + use_offset,
232-
writebuf + (use_len_max * i) + use_offset,
233-
use_len);
236+
bitflips = memcmpshowoffset(addr, use_offset,
237+
readbuf + use_offset,
238+
writebuf + (use_len_max * i) + use_offset,
239+
use_len);
234240

235241
/* verify pre-offset area for 0xff */
236242
bitflips += memffshow(addr, 0, readbuf, use_offset);

0 commit comments

Comments
 (0)