mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 04/12] nand: do not fall through in nand_scan_tail()
Date: Mon,  4 Apr 2011 16:46:36 +0200	[thread overview]
Message-ID: <1301928401-13571-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1301928401-13571-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand_base.c |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 9946066..af77868 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2288,6 +2288,23 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
 	return 0;
 }
 
+static void __maybe_unused nand_check_hwecc(struct mtd_info *mtd, struct nand_chip *chip)
+{
+	if ((!chip->ecc.calculate || !chip->ecc.correct ||
+	     !chip->ecc.hwctl) &&
+	    (!chip->ecc.read_page || !chip->ecc.write_page)) {
+		printk(KERN_WARNING "No ECC functions supplied, "
+		       "Hardware ECC not possible\n");
+		BUG();
+	}
+
+	if (mtd->writesize < chip->ecc.size) {
+		printk(KERN_WARNING "%d byte HW ECC not possible on "
+		       "%d byte page size\n",
+			chip->ecc.size, mtd->writesize);
+		BUG();
+	}
+}
 
 /**
  * nand_scan_tail - [NAND Interface] Scan for the NAND device
@@ -2356,17 +2373,10 @@ int nand_scan_tail(struct mtd_info *mtd)
 		if (!chip->ecc.write_oob)
 			chip->ecc.write_oob = nand_write_oob_std;
 
+		nand_check_hwecc(mtd, chip);
+		break;
+
 	case NAND_ECC_HW_SYNDROME:
-		if ((!chip->ecc.calculate || !chip->ecc.correct ||
-		     !chip->ecc.hwctl) &&
-		    (!chip->ecc.read_page ||
-		     chip->ecc.read_page == nand_read_page_hwecc ||
-		     !chip->ecc.write_page ||
-		     chip->ecc.write_page == nand_write_page_hwecc)) {
-			printk(KERN_WARNING "No ECC functions supplied, "
-			       "Hardware ECC not possible\n");
-			BUG();
-		}
 		/* Use standard syndrome read/write page function ? */
 		if (!chip->ecc.read_page)
 			chip->ecc.read_page = nand_read_page_syndrome;
@@ -2377,12 +2387,8 @@ int nand_scan_tail(struct mtd_info *mtd)
 		if (!chip->ecc.write_oob)
 			chip->ecc.write_oob = nand_write_oob_syndrome;
 
-		if (mtd->writesize >= chip->ecc.size)
-			break;
-		printk(KERN_WARNING "%d byte HW ECC not possible on "
-		       "%d byte page size, fallback to SW ECC\n",
-		       chip->ecc.size, mtd->writesize);
-		chip->ecc.mode = NAND_ECC_SOFT;
+		nand_check_hwecc(mtd, chip);
+		break;
 
 	case NAND_ECC_SOFT:
 		chip->ecc.calculate = nand_calculate_ecc;
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-04-04 14:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-04 14:46 Nand: make nand support more configurable Sascha Hauer
2011-04-04 14:46 ` [PATCH 01/12] commands: Make nand command optional Sascha Hauer
2011-04-04 14:46 ` [PATCH 02/12] nand: remove unused suspend/resume functions Sascha Hauer
2011-04-04 14:46 ` [PATCH 03/12] nand: remove unneeded nand_[get|release]_device functions Sascha Hauer
2011-04-04 14:46 ` Sascha Hauer [this message]
2011-04-04 14:46 ` [PATCH 05/12] nand: Factor out hw ecc support to seperate file Sascha Hauer
2011-04-04 14:46 ` [PATCH 06/12] nand: factor out software " Sascha Hauer
2011-04-04 14:46 ` [PATCH 07/12] nand: factor out syndrome " Sascha Hauer
2011-04-04 14:46 ` [PATCH 08/12] nand: factor out nand write support Sascha Hauer
2011-04-04 14:46 ` [PATCH 09/12] nand: Make write support optional Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1301928401-13571-5-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox