From patchwork Thu Oct 24 08:00:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 285809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A0AD32C00B9 for ; Thu, 24 Oct 2013 19:01:18 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZFqw-00054w-Gl; Thu, 24 Oct 2013 08:01:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZFqu-0000RY-RR; Thu, 24 Oct 2013 08:01:08 +0000 Received: from mail-pb0-x22f.google.com ([2607:f8b0:400e:c01::22f]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VZFqt-0000QU-7V for linux-mtd@lists.infradead.org; Thu, 24 Oct 2013 08:01:07 +0000 Received: by mail-pb0-f47.google.com with SMTP id rq2so1805127pbb.6 for ; Thu, 24 Oct 2013 01:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=KhaRLDDIINZO37B0GHoNJrmKuBXKvS+5Qkysi8K3hH0=; b=zaJWcjYRWseQcQwfyc30XszbqYudJspHK4svayeyl65pT4p6+Qq+q148VajscpCiuI CwFvKog5OY5eMq2RNgwAEU2TJ7NHGmgGmmVE/rIW4cS5FwEIZVwK/N2NDQWUuKmV+4is sPuPMlO9e7jMFFqnbqR91eA2alU+8yAEkrexuKF15+ozjJOd5qqYwtVJey0yAqvATe67 ewFfbFVk0e6Jz6XKCS8OGnASZaPLjz9Si7RQrUTa4FJjuW9zNu3ITCrit9XKDhC8hFKT 11x3EgKLiC8loNZX3WODMZZ6hdJsCJI3t1TMl5BMMcdjJsct3Y/AFcYrdFBz2WG1WCEn gbbg== X-Received: by 10.66.177.71 with SMTP id co7mr595722pac.181.1382601644638; Thu, 24 Oct 2013 01:00:44 -0700 (PDT) Received: from norris.computersforpeace.net (cpe-98-154-223-43.socal.res.rr.com. [98.154.223.43]) by mx.google.com with ESMTPSA id qf7sm3283366pac.14.2013.10.24.01.00.43 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 24 Oct 2013 01:00:44 -0700 (PDT) Date: Thu, 24 Oct 2013 01:00:41 -0700 From: Brian Norris To: Huang Shijie Subject: Re: [PATCH for mtd-utils] flash_erase: check the nand type Message-ID: <20131024080041.GC9863@norris.computersforpeace.net> References: <1382594766-27467-1-git-send-email-b32955@freescale.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1382594766-27467-1-git-send-email-b32955@freescale.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131024_040107_359824_4B2FC93A X-CRM114-Status: GOOD ( 17.37 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org, dedekind1@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 > --- > 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 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. > 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 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 */