From patchwork Sat Nov 1 22:08:01 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Yanok X-Patchwork-Id: 6815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 74F19DDD0B for ; Sun, 2 Nov 2008 09:11:11 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1KwOeO-0003ae-8x; Sat, 01 Nov 2008 22:08:56 +0000 Received: from ocean.emcraft.com ([213.221.7.182]) by bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux)) id 1KwOeM-0003Fj-5G for linux-mtd@lists.infradead.org; Sat, 01 Nov 2008 22:08:54 +0000 Received: from [172.17.0.9] (helo=localhost.localdomain) by ocean.emcraft.com with esmtp (Exim 4.43) id 1KwOe8-0002Gl-Pu; Sun, 02 Nov 2008 01:08:42 +0300 From: Ilya Yanok To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd-utils: try to use ECCLAYOUT ioctl if MEMGETOOBSEL fails Date: Sun, 2 Nov 2008 01:08:01 +0300 Message-Id: <1225577281-23536-1-git-send-email-yanok@emcraft.com> X-Mailer: git-send-email 1.5.6.5 X-Spam-Score: -4.3 (----) X-Spam-Report: Spam detection software, running on the system "pacific.emcraft.com", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Use newer ECCLAYOUT ioctl (if defined) in case of MEMGETOOBSEL ioctl fails inside flash_eraseall. Signed-off-by: Ilya Yanok --- flash_eraseall.c | 68 ++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 25 deletions(-) [...] Content analysis details: (-4.3 points, 2.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.1 AWL AWL: From: address is in the auto white-list X-Spam-Score: 0.0 (/) Cc: Ilya Yanok , dzu@denx.de X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use newer ECCLAYOUT ioctl (if defined) in case of MEMGETOOBSEL ioctl fails inside flash_eraseall. Signed-off-by: Ilya Yanok --- flash_eraseall.c | 68 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 43 insertions(+), 25 deletions(-) diff --git a/flash_eraseall.c b/flash_eraseall.c index 60036d3..7644ea2 100644 --- a/flash_eraseall.c +++ b/flash_eraseall.c @@ -87,38 +87,56 @@ int main (int argc, char *argv[]) struct nand_oobinfo oobinfo; if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0) { +#ifdef ECCLAYOUT + struct nand_layout layout; + if (ioctl(fd, ECCLAYOUT, &layout) != 0) { +#endif fprintf(stderr, "%s: %s: unable to get NAND oobinfo\n", exe_name, mtd_device); exit(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"); +#ifdef ECCLAYOUT + } + if (!layout.oobfree[0].length) { + fprintf(stderr, + " Eep. No empty space " + "in oob\n"); exit(1); } - clmpos = oobinfo.oobfree[0][0]; - clmlen = oobinfo.oobfree[0][1]; - if (clmlen > 8) - clmlen = 8; + clmpos = layout.oobfree[0].offset; + clmlen = layout.oobfree[0].length; +#endif } 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; + /* 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"); + exit(1); + } + clmpos = oobinfo.oobfree[0][0]; + clmlen = oobinfo.oobfree[0][1]; + } 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; + } } } + 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));