nanddump: correct rounding to next page (lead to infinite loop)
authorRichard Genoud <richard.genoud@gmail.com>
Tue, 24 Jun 2014 10:12:58 +0000 (12:12 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 25 Jun 2014 14:37:37 +0000 (16:37 +0200)
commitcbf3bfa57a419202c2bc26f3ff8ae21d3d3bf8b2
treea068db7e2be4e0edeaecead5ca210be0c48001d7
parentde3cae1348f212effd3f2838301596d15c6b3e54
nanddump: correct rounding to next page (lead to infinite loop)

The rounding to next page formula was wrong:
ex: (len | ~(meminfo->writesize - 1)) + 1;
len=128K
writesize=4K
(len | ~(meminfo->writesize - 1)) + 1 => 4 294 963 201 ?!

correct rounding formula:
((len - 1) | (meminfo->writesize - 1)) + 1 => 128K
len = 130K
((len - 1) | (meminfo->writesize - 1)) + 1 => 132K

modprobe nandsim parts="20,20" badblocks="22,23"

without patch:
nanddump  /dev/mtd1 | wc -c
[...] infinite loop

with the patch:
nanddump /dev/mtd1 | wc -c
327680

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/nandwrite.c