aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nand_base.c
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2017-04-21 12:51:07 +0200
committerBoris Brezillon <boris.brezillon@free-electrons.com>2017-06-01 10:09:24 +0200
commit086567f12e1188c57e061a53825a5eff5a7923a0 (patch)
tree1430eed25ed4cda67cd6bbb73d94b8c4b0c96270 /drivers/mtd/nand/nand_base.c
parentmtd: nand: fsmc_nand: handle on-die ECC case (diff)
downloadlinux-dev-086567f12e1188c57e061a53825a5eff5a7923a0.tar.xz
linux-dev-086567f12e1188c57e061a53825a5eff5a7923a0.zip
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: Pavel Machek <pavel@denx.de> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r--drivers/mtd/nand/nand_base.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ed08e3946727..79d98c9fa8a7 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1421,7 +1421,10 @@ static int nand_check_erased_buf(void *buf, int len, int bitflips_threshold)
for (; len >= 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;
if (unlikely(bitflips > bitflips_threshold))
return -EBADMSG;