Commit 086567f1 authored by Pavel Machek's avatar Pavel Machek Committed by Boris Brezillon

mtd: nand: Optimize checking of erased buffers

If we see ~0UL in flash, there's no need for hweight, and no need to
check number of bitflips. So this should be net win.
Signed-off-by: default avatarPavel Machek <pavel@denx.de>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 838ff7b3
...@@ -1421,7 +1421,10 @@ static int nand_check_erased_buf(void *buf, int len, int bitflips_threshold) ...@@ -1421,7 +1421,10 @@ static int nand_check_erased_buf(void *buf, int len, int bitflips_threshold)
for (; len >= sizeof(long); for (; len >= sizeof(long);
len -= sizeof(long), bitmap += sizeof(long)) { len -= sizeof(long), bitmap += sizeof(long)) {
weight = hweight_long(*((unsigned long *)bitmap)); unsigned long d = *((unsigned long *)bitmap);
if (d == ~0UL)
continue;
weight = hweight_long(d);
bitflips += BITS_PER_LONG - weight; bitflips += BITS_PER_LONG - weight;
if (unlikely(bitflips > bitflips_threshold)) if (unlikely(bitflips > bitflips_threshold))
return -EBADMSG; return -EBADMSG;
......
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