All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elizabeth Clarke <eclarke@aminocom.com>
To: linux-mtd <linux-mtd@lists.infradead.org>
Subject: Problem with ecc in drivers/mtd/nand.c
Date: Thu, 27 Jun 2002 10:41:14 +0100	[thread overview]
Message-ID: <3D1ADDBA.DD33F2A9@aminocom.com> (raw)

Hi,

Porting our in-house noddy nand filesystem to use mtd I came across a
number of problemettes. Mainly down to ecc. When writing
(nand_write_page), only half the eccvalid byte was being set when
writing the full 512bytes. And when reading (nand_read_ecc) it didn't
check the ecc at all. It also appeared the ecc valid nibbles were
inconsistent. I fixed it by simply making them consistent, but its
occurred to me that there might be a 'proper' way: written first page
then set eccvalid byte to 0x0f, write to the second page add 0xf0. Or
the other way round?

Anyway, patch attached for Thomas/David to find.

Beth

--- nand.c	Thu Jun 27 10:00:52 2002
+++ nand.new.c	Thu Jun 27 09:21:34 2002
@@ -311,7 +311,7 @@
 		for (i = 0; i < 3; i++)
 			this->data_buf[(mtd->oobblock + oob_config.ecc_pos[i])] =
ecc_code[i];
 		if (oob_config.eccvalid_pos != -1)
-			this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] = 0xf0;
+			this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] = 0x0f;
 	}
 
 	/* Calculate and write the second ECC if we have enough data */
@@ -320,7 +320,7 @@
 		for (i = 3; i < 6; i++)
 			this->data_buf[(mtd->oobblock + oob_config.ecc_pos[i])] =
ecc_code[i];
 		if (oob_config.eccvalid_pos != -1)
-			this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] &= 0x0f;
+			this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] |= 0xf0;
 	}
 #endif
 	/* Prepad for partial page programming !!! */
@@ -478,7 +478,7 @@
 		/* Calculate the ECC and verify it */
 		/* If block was not written with ECC, skip ECC */
 		if (oob_config.eccvalid_pos != -1 &&
-		    (this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] & 0x0f)
!= 0x0f) {
+		    (this->data_buf[mtd->oobblock + oob_config.eccvalid_pos] & 0x0f)
== 0x0f) {
 
 			nand_calculate_ecc (&this->data_buf[0], &ecc_calc[0]);
 			switch (nand_correct_data (&this->data_buf[0], &ecc_code[0],
&ecc_calc[0])) {
@@ -494,7 +494,7 @@
 		}
 
 		if (oob_config.eccvalid_pos != -1 &&
-		    mtd->oobblock == 512 && (this->data_buf[mtd->oobblock +
oob_config.eccvalid_pos] & 0xf0) != 0xf0) {
+		    mtd->oobblock == 512 && (this->data_buf[mtd->oobblock +
oob_config.eccvalid_pos] & 0xf0) == 0xf0) {
 
 			nand_calculate_ecc (&this->data_buf[256], &ecc_calc[3]);
 			switch (nand_correct_data (&this->data_buf[256], &ecc_code[3],
&ecc_calc[3])) {

                 reply	other threads:[~2002-06-27  9:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3D1ADDBA.DD33F2A9@aminocom.com \
    --to=eclarke@aminocom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.