Skip to contentSkip to conversation

mtd: rawnand: meson: fix bit map use in meson_nfc_ecc_correct()

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 28, 2022 – Sep 20, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: meson: fix bit map use in meson_nfc_ecc_correct()

The meson_nfc_ecc_correct() function accidentally does a right shift instead of a left shift so it only works for BIT(0). Also use BIT_ULL() because "correct_bitmap" is a u64 and we want to avoid shift wrapping bugs.

Fixes 8fae856c5350 ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")

---
From review. Untested.

 drivers/mtd/nand/raw/meson_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +2 -2
index 829b76b303aa..ad2ffd0ca800 100644
@@ -454,7 +454,7 @@ static int meson_nfc_ecc_correct(struct nand_chip *nand, u32 *bitflips,
 		if (ECC_ERR_CNT(*info) != ECC_UNCORRECTABLE) {
 			mtd->ecc_stats.corrected += ECC_ERR_CNT(*info);
 			*bitflips = max_t(u32, *bitflips, ECC_ERR_CNT(*info));
-			*correct_bitmap |= 1 >> i;
+			*correct_bitmap |= BIT_ULL(i);
 			continue;
 		}
 		if ((nand->options & NAND_NEED_SCRAMBLING) &&
@@ -800,7 +800,7 @@ static int meson_nfc_read_page_hwecc(struct nand_chip *nand, u8 *buf,
 			u8 *data = buf + i * ecc->size;
 			u8 *oob = nand->oob_poi + i * (ecc->bytes + 2);
 
-			if (correct_bitmap & (1 << i))
+			if (correct_bitmap & BIT_ULL(i))
 				continue;
 			ret = nand_check_erased_ecc_chunk(data,	ecc->size,
 							  oob, ecc->bytes + 2,
Signature · 1 line
2.35.1
maintainer Acked-by on v1 1/1
#1 lore raw

Hi Dan,

Thanks.

Quoted 29 lines · Dan Carpenter

[ EXTERNAL EMAIL ]

The meson_nfc_ecc_correct() function accidentally does a right shift instead of a left shift so it only works for BIT(0). Also use BIT_ULL() because "correct_bitmap" is a u64 and we want to avoid shift wrapping bugs.

Fixes 8fae856c5350 ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")

---

Quoted 1 line

From review. Untested.

  drivers/mtd/nand/raw/meson_nand.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +1 -1
index 829b76b303aa..ad2ffd0ca800 100644
@@ -454,7 +454,7 @@ static int meson_nfc_ecc_correct(struct nand_chip *nand, u32 *bitflips,
  		if (ECC_ERR_CNT(*info) != ECC_UNCORRECTABLE) {
  			mtd->ecc_stats.corrected += ECC_ERR_CNT(*info);
  			*bitflips = max_t(u32, *bitflips, ECC_ERR_CNT(*info));
-			*correct_bitmap |= 1 >> i;
+			*correct_bitmap |= BIT_ULL(i);
  			continue;
  		}
  		if ((nand->options & NAND_NEED_SCRAMBLING) &&

drivers/mtd/nand/raw/meson_nand.c static int meson_nfc_read_page_hwecc(struct nand_chip *nand, u8 *buf, · line 806

Quoted 8 lines
drivers/mtd/nand/raw/meson_nand.c +1 -1
@@ -800,7 +800,7 @@ static int meson_nfc_read_page_hwecc(struct nand_chip *nand, u8 *buf,
  			u8 *data = buf + i * ecc->size;
  			u8 *oob = nand->oob_poi + i * (ecc->bytes + 2);
 
-			if (correct_bitmap & (1 << i))
+			if (correct_bitmap & BIT_ULL(i))
  				continue;
  			ret = nand_check_erased_ecc_chunk(data,	ecc->size,
  							  oob, ecc->bytes + 2,

Thanks,
Liang

maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 8 lines · Dan Carpenter

The meson_nfc_ecc_correct() function accidentally does a right shift instead of a left shift so it only works for BIT(0). Also use BIT_ULL() because "correct_bitmap" is a u64 and we want to avoid shift wrapping bugs.

Fixes 8fae856c5350 ("mtd: rawnand: meson: add support for Amlogic NAND flash controller")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic