Skip to content

Commit d2b51c8

Browse files
Roger Quadroscomputersforpeace
authored andcommitted
mtd: mtd_oobtest: Fix bitflip_limit usage in test case 3
In test case 3, we set vary_offset to write at different offsets and lengths in the OOB available area. We need to do the bitflip_limit check while checking for 0xff outside the OOB offset + length area that we didn't modify during write. Signed-off-by: Roger Quadros <[email protected]> [Brian: whitespace fixup] Signed-off-by: Brian Norris <[email protected]>
1 parent 45fd357 commit d2b51c8

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

drivers/mtd/tests/oobtest.c

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,31 @@ static size_t memcmpshow(loff_t addr, const void *cs, const void *ct, size_t cou
141141
return bitflips;
142142
}
143143

144+
/*
145+
* Compare with 0xff and show the address, offset and data bytes at
146+
* comparison failure. Return number of bitflips encountered.
147+
*/
148+
static size_t memffshow(loff_t addr, loff_t offset, const void *cs,
149+
size_t count)
150+
{
151+
const unsigned char *su1;
152+
int res;
153+
size_t i = 0;
154+
size_t bitflips = 0;
155+
156+
for (su1 = cs; 0 < count; ++su1, count--, i++) {
157+
res = *su1 ^ 0xff;
158+
if (res) {
159+
pr_info("error @addr[0x%lx:0x%lx] 0x%x -> 0xff diff 0x%x\n",
160+
(unsigned long)addr, (unsigned long)offset + i,
161+
*su1, res);
162+
bitflips += hweight8(res);
163+
}
164+
}
165+
166+
return bitflips;
167+
}
168+
144169
static int verify_eraseblock(int ebnum)
145170
{
146171
int i;
@@ -203,6 +228,15 @@ static int verify_eraseblock(int ebnum)
203228
bitflips = memcmpshow(addr, readbuf + use_offset,
204229
writebuf + (use_len_max * i) + use_offset,
205230
use_len);
231+
232+
/* verify pre-offset area for 0xff */
233+
bitflips += memffshow(addr, 0, readbuf, use_offset);
234+
235+
/* verify post-(use_offset + use_len) area for 0xff */
236+
k = use_offset + use_len;
237+
bitflips += memffshow(addr, k, readbuf + k,
238+
mtd->ecclayout->oobavail - k);
239+
206240
if (bitflips > bitflip_limit) {
207241
pr_err("error: verify failed at %#llx\n",
208242
(long long)addr);
@@ -212,34 +246,8 @@ static int verify_eraseblock(int ebnum)
212246
return -1;
213247
}
214248
} else if (bitflips) {
215-
pr_info("ignoring error as within bitflip_limit\n");
249+
pr_info("ignoring errors as within bitflip limit\n");
216250
}
217-
218-
for (k = 0; k < use_offset; ++k)
219-
if (readbuf[k] != 0xff) {
220-
pr_err("error: verify 0xff "
221-
"failed at %#llx\n",
222-
(long long)addr);
223-
errcnt += 1;
224-
if (errcnt > 1000) {
225-
pr_err("error: too "
226-
"many errors\n");
227-
return -1;
228-
}
229-
}
230-
for (k = use_offset + use_len;
231-
k < mtd->ecclayout->oobavail; ++k)
232-
if (readbuf[k] != 0xff) {
233-
pr_err("error: verify 0xff "
234-
"failed at %#llx\n",
235-
(long long)addr);
236-
errcnt += 1;
237-
if (errcnt > 1000) {
238-
pr_err("error: too "
239-
"many errors\n");
240-
return -1;
241-
}
242-
}
243251
}
244252
if (vary_offset)
245253
do_vary_offset();

0 commit comments

Comments
 (0)