diff mbox

[U-Boot] omap-gpmc: use SECTOR_BYTES instead of hardcoded value

Message ID 20170109101514.eqprnde7tjowneod@lenoch
State Accepted
Commit 6fe7fe12ccfe4e3f068e6adb624a3092e7e852c9
Delegated to: Tom Rini
Headers show

Commit Message

Ladislav Michl Jan. 9, 2017, 10:15 a.m. UTC
Replace hardcoded value with defined constant SECTOR_BYTES.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
 drivers/mtd/nand/omap_gpmc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Tom Rini Jan. 10, 2017, 11:14 p.m. UTC | #1
On Mon, Jan 09, 2017 at 11:15:14AM +0100, Ladislav Michl wrote:

> Replace hardcoded value with defined constant SECTOR_BYTES.
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini Jan. 15, 2017, 6:32 p.m. UTC | #2
On Mon, Jan 09, 2017 at 11:15:14AM +0100, Ladislav Michl wrote:

> Replace hardcoded value with defined constant SECTOR_BYTES.
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c
index d1e1bdda28..f4f0de395b 100644
--- a/drivers/mtd/nand/omap_gpmc.c
+++ b/drivers/mtd/nand/omap_gpmc.c
@@ -656,14 +656,14 @@  static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,
 	struct nand_chip *chip = mtd_to_nand(mtd);
 	struct omap_nand_info *info = nand_get_controller_data(chip);
 
-	count = decode_bch(info->control, NULL, 512, read_ecc, calc_ecc,
-							NULL, errloc);
+	count = decode_bch(info->control, NULL, SECTOR_BYTES,
+				read_ecc, calc_ecc, NULL, errloc);
 	if (count > 0) {
 		/* correct errors */
 		for (i = 0; i < count; i++) {
 			/* correct data only, not ecc bytes */
-			if (errloc[i] < 8*512)
-				data[errloc[i]/8] ^= 1 << (errloc[i] & 7);
+			if (errloc[i] < SECTOR_BYTES << 3)
+				data[errloc[i] >> 3] ^= 1 << (errloc[i] & 7);
 			debug("corrected bitflip %u\n", errloc[i]);
 #ifdef DEBUG
 			puts("read_ecc: ");