From: Pantelis Antoniou <panto@intracom.gr>
To: David Woodhouse <dwmw2@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-mtd@lists.infradead.org
Subject: [PATCH] Various fixes for NAND.
Date: Thu, 06 May 2004 10:10:20 +0300 [thread overview]
Message-ID: <4099E4DC.6030401@intracom.gr> (raw)
[-- Attachment #1: Type: text/plain, Size: 309 bytes --]
Hello
The following patch does two things.
1. Adds an erase_shift member to the nand_chip structure
so that we can avoid multiplications and divisions.
2. Makes the autoob the default oobinfo so that when no access
from user space is made to fill it, it doesn't default to no ECC.
Regards
Pantelis
[-- Attachment #2: various.diff --]
[-- Type: text/x-patch, Size: 2713 bytes --]
diff -ruN mtd-original/drivers/mtd/mtdpart.c mtd-work/drivers/mtd/mtdpart.c
--- mtd-original/drivers/mtd/mtdpart.c 2004-03-30 01:00:17.000000000 +0300
+++ mtd-work/drivers/mtd/mtdpart.c 2004-05-06 10:00:40.449248560 +0300
@@ -485,6 +485,9 @@
parts[i].name);
}
+ /* copy oobinfo from master */
+ memcpy(&slave->mtd.oobinfo, &master->oobinfo, sizeof(slave->mtd.oobinfo));
+
if(parts[i].mtdp)
{ /* store the object pointer (caller may or may not register it */
*parts[i].mtdp = &slave->mtd;
diff -ruN mtd-original/drivers/mtd/nand/nand.c mtd-work/drivers/mtd/nand/nand.c
--- mtd-original/drivers/mtd/nand/nand.c 2004-05-05 01:00:35.000000000 +0300
+++ mtd-work/drivers/mtd/nand/nand.c 2004-05-06 10:01:55.231879872 +0300
@@ -1163,7 +1163,7 @@
/* Check, if the buffer must be filled with ff again */
if (this->oobdirty) {
memset (this->oob_buf, 0xff,
- mtd->oobsize * (mtd->erasesize / mtd->oobblock));
+ mtd->oobsize << (this->erase_shift - this->page_shift));
this->oobdirty = 0;
}
@@ -1671,7 +1671,7 @@
chipnr = (int)((unsigned long)instr->addr / this->chipsize);
/* Calculate pages in each block */
- pages_per_block = mtd->erasesize / mtd->oobblock;
+ pages_per_block = 1 << (this->erase_shift - this->page_shift);
/* Select the NAND device */
this->select_chip(mtd, chipnr);
@@ -1941,6 +1941,7 @@
/* Calculate the address shift from the page size */
this->page_shift = ffs(mtd->oobblock) - 1;
+ this->erase_shift = ffs(mtd->erasesize) - 1;
/* Set the bad block position */
this->badblockpos = mtd->oobblock > 512 ?
@@ -1994,7 +1995,7 @@
/* Convert chipsize to number of pages per chip -1. */
this->pagemask = (this->chipsize >> this->page_shift) - 1;
/* Preset the internal oob buffer */
- memset(this->oob_buf, 0xff, mtd->oobsize * (mtd->erasesize / mtd->oobblock));
+ memset(this->oob_buf, 0xff, mtd->oobsize << (this->erase_shift - this->page_shift));
/* If no default placement scheme is given, select an
* appropriate one */
@@ -2120,6 +2121,10 @@
mtd->resume = NULL;
mtd->block_isbad = nand_block_isbad;
mtd->block_markbad = nand_block_markbad;
+
+ /* and make the autooob the default one */
+ memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo));
+
mtd->owner = THIS_MODULE;
/* Return happy */
diff -ruN mtd-original/include/linux/mtd/nand.h mtd-work/include/linux/mtd/nand.h
--- mtd-original/include/linux/mtd/nand.h 2004-04-17 01:00:05.000000000 +0300
+++ mtd-work/include/linux/mtd/nand.h 2004-05-06 09:59:30.404896920 +0300
@@ -235,6 +235,7 @@
wait_queue_head_t wq;
nand_state_t state;
int page_shift;
+ int erase_shift;
u_char *data_buf;
u_char *oob_buf;
int oobdirty;
[-- Attachment #3: various.diffstat --]
[-- Type: text/plain, Size: 168 bytes --]
drivers/mtd/mtdpart.c | 3 +++
drivers/mtd/nand/nand.c | 11 ++++++++---
include/linux/mtd/nand.h | 1 +
3 files changed, 12 insertions(+), 3 deletions(-)
reply other threads:[~2004-05-06 7:22 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=4099E4DC.6030401@intracom.gr \
--to=panto@intracom.gr \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=tglx@linutronix.de \
/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