From patchwork Mon Mar 23 22:42:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 24937 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 86702DE05D for ; Tue, 24 Mar 2009 17:01:08 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1Llzdt-0002dM-PT; Tue, 24 Mar 2009 05:57:41 +0000 Received: from chamillionaire.breakpoint.cc ([85.10.199.196]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1Llsqb-0001p4-VP for linux-mtd@lists.infradead.org; Mon, 23 Mar 2009 22:42:35 +0000 Received: id: bigeasy by Chamillionaire.breakpoint.cc authenticated by bigeasy with local (easymta 1.00 BETA 1) id 1LlsqY-0004mj-ET; Mon, 23 Mar 2009 23:42:18 +0100 From: Sebastian Andrzej Siewior To: linux-mtd@lists.infradead.org Subject: [PATCH] flash_eraseall: only add cleanmarkers on known flashtypes Date: Mon, 23 Mar 2009 23:42:17 +0100 Message-Id: <1237848138-18157-3-git-send-email-sebastian@breakpoint.cc> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1237848138-18157-1-git-send-email-sebastian@breakpoint.cc> References: <1237848138-18157-1-git-send-email-sebastian@breakpoint.cc> X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Tue, 24 Mar 2009 01:57:37 -0400 Cc: Sebastian Andrzej Siewior X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.11 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 - data flash and an UBI flash do not use clean markers. Do not create them, even if the users says so. - don't generate clean markers on unknown media/new media. Theoreticly nobody should use jffs2 on new media anyway :) Signed-off-by: Sebastian Andrzej Siewior --- flash_eraseall.c | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/flash_eraseall.c b/flash_eraseall.c index 3da56ee..0a4010e 100644 --- a/flash_eraseall.c +++ b/flash_eraseall.c @@ -60,12 +60,25 @@ static int clmlen = 8; static int prepare_clean_marker(mtd_info_t *meminfo) { + struct nand_oobinfo oobinfo; + cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); - if (meminfo->type != MTD_NANDFLASH) + + switch (meminfo->type) { + case MTD_ROM: + case MTD_RAM: + case MTD_NORFLASH: cleanmarker.totlen = cpu_to_je32(sizeof(struct jffs2_unknown_node)); - else { - struct nand_oobinfo oobinfo; + break; + + case MTD_DATAFLASH: + case MTD_UBIVOLUME: + fprintf(stderr, "JFFS2 layout not supported on this flash.\n"); + return -1; + break; + + case MTD_NANDFLASH: if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0) { fprintf(stderr, "%s: %s: unable to get NAND oobinfo\n", @@ -103,6 +116,12 @@ static int prepare_clean_marker(mtd_info_t *meminfo) } } cleanmarker.totlen = cpu_to_je32(8); + break; + default: + fprintf(stderr, "Unknown flash type, just erasing\n"); + return -1; + break; + } cleanmarker.hdr_crc = cpu_to_je32(crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node) - 4));