diff options
author | Pavel Machek <pavel@ucw.cz> | 2017-04-21 12:51:07 +0200 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2017-06-01 10:09:24 +0200 |
commit | 086567f12e1188c57e061a53825a5eff5a7923a0 (patch) | |
tree | 1430eed25ed4cda67cd6bbb73d94b8c4b0c96270 /drivers/mtd | |
parent | 838ff7b333263abc9e7e026bb225ed66511f450f (diff) | |
download | linux-086567f12e1188c57e061a53825a5eff5a7923a0.tar.bz2 |
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')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 5 |
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; |