From: Brian Norris <computersforpeace@gmail.com>
To: Huang Shijie <b32955@freescale.com>
Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org, dedekind1@gmail.com
Subject: Re: [PATCH for mtd-utils] flash_erase: check the nand type
Date: Thu, 24 Oct 2013 01:00:41 -0700 [thread overview]
Message-ID: <20131024080041.GC9863@norris.computersforpeace.net> (raw)
In-Reply-To: <1382594766-27467-1-git-send-email-b32955@freescale.com>
On Thu, Oct 24, 2013 at 02:06:06PM +0800, Huang Shijie wrote:
> Now, the MTD_NANDFLASH stands for SLC nand, and the MTD_MLCNANDFLASH
> stands for the MLC nand.
>
> This patch checks the right nand type for the MLC and SLC nand.
> And if it is a MLC nand, we do not write cleanmarker for it, only print
> out a message to warn the user.
>
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
> flash_erase.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/flash_erase.c b/flash_erase.c
> index 1421cf9..dd75334 100644
> --- a/flash_erase.c
> +++ b/flash_erase.c
> @@ -184,7 +184,8 @@ int main(int argc, char *argv[])
>
> eb_start = start / mtd.eb_size;
>
> - isNAND = mtd.type == MTD_NANDFLASH ? 1 : 0;
> + isNAND = (mtd.type == MTD_NANDFLASH || mtd.type == MTD_MLCNANDFLASH)
> + ? 1 : 0;
Perhaps you can #include <stdbool.h> and make 'isNAND' into a proper
bool variable? Then this becomes:
isNAND = mtd.type == MTD_NANDFLASH || mtd.type == MTD_MLCNANDFLASH;
>
> if (jffs2) {
> cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
> @@ -272,6 +273,12 @@ int main(int argc, char *argv[])
>
> /* write cleanmarker */
> if (isNAND) {
> + if (mtd.type == MTD_MLCNANDFLASH) {
> + sys_errmsg("%s: we can't write the cleanmarker "
> + "for the MLC nand.", mtd_device);
> + continue;
> + }
> +
This is in a loop. This will print the same message repeatedly if you
are erasing/marking an entire partition. Please test your changes before
sending v2.
You could probably just error out (or warn) like the following.
diff --git a/flash_erase.c b/flash_erase.c
index 1421cf9..0e385e9 100644
--- a/flash_erase.c
+++ b/flash_erase.c
@@ -169,6 +169,9 @@ int main(int argc, char *argv[])
if (error)
return errmsg("Try `--help' for more information");
+ if (jffs2 && mtd.type == MTD_MLCNANDFLASH)
+ return errmsg("JFFS2 cannot support MLC NAND");
+
/*
* Locate MTD and prepare for erasure
*/
> if (mtd_write_oob(mtd_desc, &mtd, fd, (uint64_t)offset + clmpos, clmlen, &cleanmarker) != 0) {
> sys_errmsg("%s: MTD writeoob failure", mtd_device);
> continue;
Brian
prev parent reply other threads:[~2013-10-24 8:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 6:06 [PATCH for mtd-utils] flash_erase: check the nand type Huang Shijie
2013-10-24 8:00 ` Brian Norris [this message]
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=20131024080041.GC9863@norris.computersforpeace.net \
--to=computersforpeace@gmail.com \
--cc=b32955@freescale.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--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;
as well as URLs for NNTP newsgroup(s).