From: "Stanley.Miao" <stanley.miao@windriver.com>
To: linux-mtd@lists.infradead.org
Subject: [PATCH 4/5] Discard the legacy interface MEMGETOOBSEL in flash_eraseall
Date: Wed, 3 Feb 2010 10:56:35 +0800 [thread overview]
Message-ID: <1265165796-24686-5-git-send-email-stanley.miao@windriver.com> (raw)
In-Reply-To: <1265165796-24686-4-git-send-email-stanley.miao@windriver.com>
The ioctl command "MEMGETOOBSEL" is not suitable with some platforms with
the NAND ECC data longer than 32 bytes, so replace it with the new command
"ECCGETLAYOUT".
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
flash_eraseall.c | 42 ++++++++++++------------------------------
1 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/flash_eraseall.c b/flash_eraseall.c
index a22fc49..1842906 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -84,41 +84,23 @@ int main (int argc, char *argv[])
if (!isNAND)
cleanmarker.totlen = cpu_to_je32 (sizeof (struct jffs2_unknown_node));
else {
- struct nand_oobinfo oobinfo;
+ struct nand_ecclayout ecclayout;
- if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0) {
- fprintf(stderr, "%s: %s: unable to get NAND oobinfo\n", exe_name, mtd_device);
+ if (ioctl(fd, ECCGETLAYOUT, &ecclayout) != 0) {
+ fprintf(stderr, "%s: %s: unable to get NAND oob layout\n",
+ exe_name, mtd_device);
return 1;
}
- /* Check for autoplacement */
- if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
- /* Get the position of the free bytes */
- if (!oobinfo.oobfree[0][1]) {
- fprintf (stderr, " Eeep. Autoplacement selected and no empty space in oob\n");
- return 1;
- }
- clmpos = oobinfo.oobfree[0][0];
- clmlen = oobinfo.oobfree[0][1];
- if (clmlen > 8)
- clmlen = 8;
- } else {
- /* Legacy mode */
- switch (meminfo.oobsize) {
- case 8:
- clmpos = 6;
- clmlen = 2;
- break;
- case 16:
- clmpos = 8;
- clmlen = 8;
- break;
- case 64:
- clmpos = 16;
- clmlen = 8;
- break;
- }
+ /* Get the position of the free bytes */
+ if (!ecclayout.oobfree[0].length) {
+ fprintf(stderr, " Eeep. Autoplacement selected and no empty space in oob\n");
+ return 1;
}
+ clmpos = ecclayout.oobfree[0].offset;
+ clmlen = ecclayout.oobfree[0].length;
+ if (clmlen > 8)
+ clmlen = 8;
cleanmarker.totlen = cpu_to_je32(8);
}
cleanmarker.hdr_crc = cpu_to_je32 (crc32 (0, &cleanmarker, sizeof (struct jffs2_unknown_node) - 4));
--
1.5.4.3
next prev parent reply other threads:[~2010-02-03 2:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-03 2:56 Stanley.Miao
2010-02-03 2:56 ` [PATCH 1/5] clean up the legacy interfaces in nandwrite.c Stanley.Miao
2010-02-03 2:56 ` [PATCH 2/5] check if the start address is page-aligned Stanley.Miao
2010-02-03 2:56 ` [PATCH 3/5] Fix the bug of writing a yaffs2 image to NAND Stanley.Miao
2010-02-03 2:56 ` Stanley.Miao [this message]
2010-02-03 2:56 ` [PATCH 5/5] Place the cleanmarker in OOB area according to the mode MTD_OOB_AUTO Stanley.Miao
2010-02-03 3:16 ` Mike Frysinger
2010-02-03 4:31 ` Re: stanley.miao
-- strict thread matches above, loose matches on Subject: below --
2010-02-03 4:45 Fix mtd-utils bugs Stanley.Miao
2010-02-03 4:45 ` [PATCH 1/5] clean up the legacy interfaces in nandwrite.c Stanley.Miao
2010-02-03 4:45 ` [PATCH 2/5] check if the start address is page-aligned Stanley.Miao
2010-02-03 4:45 ` [PATCH 3/5] Fix the bug of writing a yaffs2 image to NAND Stanley.Miao
2010-02-03 4:45 ` [PATCH 4/5] Discard the legacy interface MEMGETOOBSEL in flash_eraseall Stanley.Miao
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=1265165796-24686-5-git-send-email-stanley.miao@windriver.com \
--to=stanley.miao@windriver.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.