public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Zach Sadecki <zsadecki@itwatchdogs.com>
To: <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: [PATCH] mtd: gpmi: Always report ECC stats and return max_bitflips
Date: Thu, 13 Dec 2012 20:36:29 -0600	[thread overview]
Message-ID: <50CA90AD.8010800@itwatchdogs.com> (raw)
In-Reply-To: <1355398036.3400.45.camel@sauron.fi.intel.com>

Always report corrected and failed ECC stats back up to the MTD layer.  Also
return max_bitflips from read_page() as is expected from NAND drivers now.

Signed-off-by: Zach Sadecki <zsadecki@itwatchdogs.com>
Acked-by: Huang Shijie <b32955 at freescale.com>
---
  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   27 ++++++++-------------------
  1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 5cd141f..1535bd5 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -921,8 +921,7 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  	dma_addr_t    auxiliary_phys;
  	unsigned int  i;
  	unsigned char *status;
-	unsigned int  failed;
-	unsigned int  corrected;
+	unsigned int  max_bitflips = 0;
  	int           ret;
  
  	pr_debug("page number is : %d\n", page);
@@ -946,35 +945,25 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  			payload_virt, payload_phys);
  	if (ret) {
  		pr_err("Error in ECC-based read: %d\n", ret);
-		goto exit_nfc;
+		return ret;
  	}
  
  	/* handle the block mark swapping */
  	block_mark_swapping(this, payload_virt, auxiliary_virt);
  
  	/* Loop over status bytes, accumulating ECC status. */
-	failed		= 0;
-	corrected	= 0;
-	status		= auxiliary_virt + nfc_geo->auxiliary_status_offset;
+	status = auxiliary_virt + nfc_geo->auxiliary_status_offset;
  
  	for (i = 0; i < nfc_geo->ecc_chunk_count; i++, status++) {
  		if ((*status == STATUS_GOOD) || (*status == STATUS_ERASED))
  			continue;
  
  		if (*status == STATUS_UNCORRECTABLE) {
-			failed++;
+			mtd->ecc_stats.failed++;
  			continue;
  		}
-		corrected += *status;
-	}
-
-	/*
-	 * Propagate ECC status to the owning MTD only when failed or
-	 * corrected times nearly reaches our ECC correction threshold.
-	 */
-	if (failed || corrected >= (nfc_geo->ecc_strength - 1)) {
-		mtd->ecc_stats.failed    += failed;
-		mtd->ecc_stats.corrected += corrected;
+		mtd->ecc_stats.corrected += *status;
+		max_bitflips = max_t(unsigned int, max_bitflips, *status);
  	}
  
  	if (oob_required) {
@@ -996,8 +985,8 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
  			this->payload_virt, this->payload_phys,
  			nfc_geo->payload_size,
  			payload_virt, payload_phys);
-exit_nfc:
-	return ret;
+
+	return max_bitflips;
  }
  
  static int gpmi_ecc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
-- 
1.7.9.5

  reply	other threads:[~2012-12-14  2:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-03 19:48 [PATCH] mtd: gpmi: Always report ECC stats and return max_bitflips Zach Sadecki
2012-12-04  3:34 ` Huang Shijie
2012-12-04 14:40   ` Zach Sadecki
2012-12-05  3:04     ` Huang Shijie
2012-12-10 13:44 ` Artem Bityutskiy
2012-12-10 15:10   ` Zach Sadecki
2012-12-10 15:18   ` Zach Sadecki
2012-12-12 15:17     ` Artem Bityutskiy
2012-12-12 16:57       ` Zach Sadecki
2012-12-13 11:27     ` Artem Bityutskiy
2012-12-14  2:36       ` Zach Sadecki [this message]
2012-12-14  2:36       ` Zach Sadecki
2013-01-10  3:01         ` Huang Shijie
2013-01-15  9:30         ` Artem Bityutskiy
2012-12-14  2:39       ` Zach Sadecki
2013-01-10  3:28         ` Huang Shijie
2013-01-10 15:40           ` Zach Sadecki

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=50CA90AD.8010800@itwatchdogs.com \
    --to=zsadecki@itwatchdogs.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@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