Skip to contentSkip to conversation

mtd: nand_omap_gpmc: Remove unused code

PATCH Applied Teresa Gámez 2 participants 3 messages Mar 30, 2015

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

PATCH 1/2 mtd: nand_omap_gpmc: Remove unused code

The ecc layout structs are not used anywhere.

---
 drivers/mtd/nand/nand_omap_gpmc.c | 68 ---------------------------------------
 1 file changed, 68 deletions(-)
drivers/mtd/nand/nand_omap_gpmc.c +0 -68
index d254042..647605b 100644
@@ -130,53 +130,6 @@ static struct nand_bbt_descr bb_descrip_flashbased = {
 	.pattern = scan_ff_pattern,
 };
 
-/** Large Page x8 NAND device Layout */
-static struct nand_ecclayout ecc_lp_x8 = {
-	.eccbytes = 12,
-	.eccpos = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
-	.oobfree = {
-		{
-			.offset = 60,
-			.length = 2,
-		}
-	}
-};
-
-/** Large Page x16 NAND device Layout */
-static struct nand_ecclayout ecc_lp_x16 = {
-	.eccbytes = 12,
-	.eccpos = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13},
-	.oobfree = {
-		{
-			.offset = 60,
-			.length = 2,
-		}
-	}
-};
-
-/** Small Page x8 NAND device Layout */
-static struct nand_ecclayout ecc_sp_x8 = {
-	.eccbytes = 3,
-	.eccpos = {1, 2, 3},
-	.oobfree = {
-		{
-			.offset = 14,
-			.length = 2,
-		}
-	}
-};
-
-/** Small Page x16 NAND device Layout */
-static struct nand_ecclayout ecc_sp_x16 = {
-	.eccbytes = 3,
-	.eccpos = {2, 3, 4},
-	.oobfree = {
-		{
-			.offset = 14,
-			.length = 2 }
-	}
-};
-
 /**
  * @brief calls the platform specific dev_ready functionds
  *
@@ -891,7 +844,6 @@ static int gpmc_nand_probe(struct device_d *pdev)
 	struct mtd_info *minfo;
 	void __iomem *cs_base;
 	int err;
-	struct nand_ecclayout *layout, *lsp, *llp;
 
 	pdata = (struct gpmc_nand_platform_data *)pdev->platform_data;
 	if (pdata == NULL) {
@@ -1012,26 +964,6 @@ static int gpmc_nand_probe(struct device_d *pdev)
 
 	gpmc_set_buswidth(nand, nand->options & NAND_BUSWIDTH_16);
 
-	if (nand->options & NAND_BUSWIDTH_16) {
-		lsp = &ecc_sp_x16;
-		llp = &ecc_lp_x16;
-	} else {
-		lsp = &ecc_sp_x8;
-		llp = &ecc_lp_x8;
-	}
-
-	switch (minfo->writesize) {
-	case 512:
-		layout = lsp;
-		break;
-	case 2048:
-		layout = llp;
-		break;
-	default:
-		err = -EINVAL;
-		goto out_release_mem;
-	}
-
 	nand->read_buf   = omap_read_buf_pref;
 	if (IS_ENABLED(CONFIG_MTD_WRITE))
 		nand->write_buf  = omap_write_buf_pref;
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/2 mtd: nand_omap_gpmc: Fix ecc check for bch8 romcode

The bch8 romcode was only checked and corrected for the first 512 bytes of a 2048 byte page. Set interation counter and eccsizes correct for the different bch types.

Tested OMAP_ECC_BCH8_CODE_HW and OMAP_ECC_BCH8_CODE_HW_ROMCODE.

---
 drivers/mtd/nand/nand_omap_gpmc.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
drivers/mtd/nand/nand_omap_gpmc.c +23 -15
index 647605b..9d9d27e 100644
@@ -298,37 +298,45 @@ static int omap_correct_bch(struct mtd_info *mtd, uint8_t *dat,
 {
 	struct nand_chip *nand = (struct nand_chip *)(mtd->priv);
 	struct gpmc_nand_info *oinfo = (struct gpmc_nand_info *)(nand->priv);
-	int i, j, eccsize, eccflag, count, totalcount;
+	int i, j, eccflag, count, totalcount, actual_eccsize;
 	unsigned int err_loc[8];
-	int blocks = 0;
 	int select_4_8;
 
-	if (oinfo->ecc_mode == OMAP_ECC_BCH4_CODE_HW) {
-		eccsize = 7;
+	int eccsteps = oinfo->nand.ecc.steps;
+	int eccsize = oinfo->nand.ecc.bytes;
+
+	switch (oinfo->ecc_mode) {
+	case OMAP_ECC_BCH4_CODE_HW:
+		actual_eccsize = eccsize;
 		select_4_8 = 0;
-	} else {
-		eccsize = 13;
+		break;
+	case OMAP_ECC_BCH8_CODE_HW:
+		eccsize /= eccsteps;
+		actual_eccsize = eccsize;
+		select_4_8 = 1;
+		break;
+	case OMAP_ECC_BCH8_CODE_HW_ROMCODE:
+		actual_eccsize = eccsize - 1;
 		select_4_8 = 1;
+		break;
+	default:
+		dev_err(oinfo->pdev, "invalid driver configuration\n");
+		return -EINVAL;
 	}
 
-	if (nand->ecc.size  == 2048)
-		blocks = 4;
-	else
-		blocks = 1;
-
 	totalcount = 0;
 
-	for (i = 0; i < blocks; i++) {
+	for (i = 0; i < eccsteps; i++) {
 		/* check if any ecc error */
 		eccflag = 0;
-		for (j = 0; (j < eccsize) && (eccflag == 0); j++) {
+		for (j = 0; (j < actual_eccsize) && (eccflag == 0); j++) {
 			if (calc_ecc[j] != 0)
 				eccflag = 1;
 		}
 
 		if (eccflag == 1) {
 			eccflag = 0;
-			for (j = 0; (j < eccsize) &&
+			for (j = 0; (j < actual_eccsize) &&
 					(eccflag == 0); j++)
 				if (read_ecc[j] != 0xFF)
 					eccflag = 1;
@@ -350,7 +358,7 @@ static int omap_correct_bch(struct mtd_info *mtd, uint8_t *dat,
 			/* else, not interested to correct ecc */
 		}
 
-		calc_ecc = calc_ecc + eccsize;
+		calc_ecc = calc_ecc + actual_eccsize;
 		read_ecc = read_ecc + eccsize;
 		dat += 512;
 	}
Signature · 7 lines
1.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#2 lore raw
In reply to Teresa Gámez
Quoted 6 lines · Teresa Gámez

The ecc layout structs are not used anywhere.

---
 drivers/mtd/nand/nand_omap_gpmc.c | 68 ---------------------------------------
 1 file changed, 68 deletions(-)

Applied both, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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