diff options
author | Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com> | 2016-04-12 15:30:35 +0800 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2016-04-19 22:04:53 +0200 |
commit | 03a97550941d17c7d5b621afde5945bbc0da6546 (patch) | |
tree | ddc3880ce6dfb086056a73cd02d3125a0df77495 | |
parent | 7a654172161c8c9c7d59cbd0054d9e63c7411219 (diff) | |
download | linux-stable-03a97550941d17c7d5b621afde5945bbc0da6546.tar.gz linux-stable-03a97550941d17c7d5b621afde5945bbc0da6546.tar.bz2 linux-stable-03a97550941d17c7d5b621afde5945bbc0da6546.zip |
mtd: nand: s3c2410: fix bug in s3c2410_nand_correct_data()
If there is only one bit difference in the ECC, the function should
return 1.
The result of "diff0 & ~(1<<fls(diff0))" is equal to diff0, so the
function actually returns -1.
Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
-rw-r--r-- | drivers/mtd/nand/s3c2410.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 9c9397b54b2c..86ffb73e1085 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -542,7 +542,8 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, diff0 |= (diff1 << 8); diff0 |= (diff2 << 16); - if ((diff0 & ~(1<<fls(diff0))) == 0) + /* equal to "(diff0 & ~(1 << __ffs(diff0)))" */ + if ((diff0 & (diff0 - 1)) == 0) return 1; return -1; |