From patchwork Mon Mar 23 22:42:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC/PATCH] flash_eraseall: extra care if NOR flash is not BIT_WRITEABLE Date: Mon, 23 Mar 2009 12:42:18 -0000 From: Sebastian Siewior X-Patchwork-Id: 24938 Message-Id: <1237848138-18157-4-git-send-email-sebastian@breakpoint.cc> To: linux-mtd@lists.infradead.org Cc: Sebastian Andrzej Siewior this is difficult because it depends on CONFIG_JFFS2_FS_WRITEBUFFER Signed-off-by: Sebastian Andrzej Siewior --- flash_eraseall.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/flash_eraseall.c b/flash_eraseall.c index 0a4010e..3591db5 100644 --- a/flash_eraseall.c +++ b/flash_eraseall.c @@ -64,12 +64,24 @@ static int prepare_clean_marker(mtd_info_t *meminfo) cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); + cleanmarker.totlen = cpu_to_je32(sizeof(struct jffs2_unknown_node)); switch (meminfo->type) { case MTD_ROM: case MTD_RAM: + break; + case MTD_NORFLASH: - cleanmarker.totlen = cpu_to_je32(sizeof(struct jffs2_unknown_node)); + /* only if the kernel is compiled with + * CONFIG_JFFS2_FS_WRITEBUFFER + * Now, how to check that? + */ + if (!(meminfo->flags & MTD_BIT_WRITEABLE)) { + int l; + + l = meminfo->writesize > 16 ? meminfo->writesize : 16; + cleanmarker.totlen = cpu_to_je32(l); + } break; case MTD_DATAFLASH: