From trini at infradead.org  Tue Apr  1 13:07:16 2003
From: trini at infradead.org (trini@infradead.org)
Date: Mon May 15 21:48:05 2006
Subject: mtd/drivers/mtd/maps redwood.c,1.1,1.2
Message-ID: <E190QAG-000611-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv23109

Modified Files:
	redwood.c 
Log Message:
Update the copyright / GPL notice (shorter now).
Add support for the rest of the Redwood plaforms.
Consistent whitespacing.


Index: redwood.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/redwood.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- redwood.c	2 May 2002 23:19:40 -0000	1.1
+++ redwood.c	1 Apr 2003 18:07:13 -0000	1.2
@@ -1,35 +1,20 @@
 /*
  * $Id:
  *
- * redwood.c - mapper for IBM Redwood-4/5 board.
- *	
- * Copyright 2001 MontaVista Softare Inc. 
- *  
- * This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.    
- *  
- *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR   IMPLIED
- *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT,  INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
- *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *  
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
+ * drivers/mtd/maps/redwood.c
  *
- *  History: 12/17/2001 - Armin
- *  		migrated to use do_map_probe
+ * FLASH map for the IBM Redwood 4/5/6 boards.
  *
+ *
+ * Author: Armin Kuster <akuster@mvista.com>
+ *
+ * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -39,135 +24,195 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/io.h>
+#define STBXX_VPD_SZ	0x10000
+#define STBXX_OB_SZ	0x20000
+#define STBXX_4MB	0x4000000
 
+#if !defined (CONFIG_REDWOOD_6)
 #define WINDOW_ADDR 0xffc00000
 #define WINDOW_SIZE 0x00400000
 
+#define RW_PART0_OF	0
+#define RW_PART0_SZ	0x10000
+#define RW_PART1_OF	RW_PART0_SZ
+#define RW_PART1_SZ	0x200000 - 0x10000
+#define RW_PART2_OF	0x200000
+#define RW_PART2_SZ	0x10000
+#define RW_PART3_OF	0x210000
+#define RW_PART3_SZ	0x200000 - (0x10000 + 0x20000)
+#define RW_PART4_OF	0x3e0000
+#define RW_PART4_SZ	0x20000
+static struct mtd_partition redwood_flash_partitions[] = {
+	{
+		name: "Redwood OpenBIOS Vital Product Data",
+		offset: RW_PART0_OF,
+		size: RW_PART0_SZ,
+		mask_flags: MTD_WRITEABLE	/* force read-only */
+	},
+	{
+		name: "Redwood kernel",
+		offset: RW_PART1_OF,
+		size: RW_PART1_SZ
+	},
+	{
+		name: "Redwood OpenBIOS non-volatile storage",
+		offset: RW_PART2_OF,
+		size: RW_PART2_SZ,
+		mask_flags: MTD_WRITEABLE	/* force read-only */
+	},
+	{
+		name: "Redwood filesystem",
+		offset: RW_PART3_OF,
+		size: RW_PART3_SZ
+	},
+	{
+		name: "Redwood OpenBIOS",
+		offset: RW_PART4_OF,
+		size: RW_PART4_SZ,
+		mask_flags: MTD_WRITEABLE	/* force read-only */
+	}
+};
+
+#else
+/* FIXME: the window is bigger - armin */
+#define WINDOW_ADDR 0xff800000
+#define WINDOW_SIZE 0x00800000
+
+#define RW_PART0_OF	0
+#define RW_PART0_SZ	0x400000	/* 4 MB data */
+#define RW_PART1_OF	RW_PART0_OF + RW_PART0_SZ 
+#define RW_PART1_SZ	0x10000		/* 64K VPD */
+#define RW_PART2_OF	RW_PART1_OF + RW_PART1_SZ
+#define RW_PART2_SZ	0x400000 - (0x10000 + 0x20000)
+#define RW_PART3_OF	RW_PART2_OF + RW_PART2_SZ
+#define RW_PART3_SZ	0x20000
+static struct mtd_partition redwood_flash_partitions[] = {
+	{
+		name: "Redwood kernel",
+		offset: RW_PART0_OF,
+		size: RW_PART0_SZ
+	},
+	{
+		name: "Redwood OpenBIOS Vital Product Data",
+		offset: RW_PART1_OF,
+		size: RW_PART1_SZ,
+		mask_flags: MTD_WRITEABLE	/* force read-only */
+	},
+	{
+		name: "Redwood filesystem",
+		offset: RW_PART2_OF,
+		size: RW_PART2_SZ
+	},
+	{
+		name: "Redwood OpenBIOS",
+		offset: RW_PART3_OF,
+		size: RW_PART3_SZ,
+		mask_flags: MTD_WRITEABLE	/* force read-only */
+	}
+};
+
+#endif
+
 __u8 redwood_flash_read8(struct map_info *map, unsigned long ofs)
 {
-        return *(__u8 *)(map->map_priv_1 + ofs);
+	return *(__u8 *)(map->map_priv_1 + ofs);
 }
 
 __u16 redwood_flash_read16(struct map_info *map, unsigned long ofs)
 {
-        return *(__u16 *)(map->map_priv_1 + ofs);
+	return *(__u16 *)(map->map_priv_1 + ofs);
 }
 
 __u32 redwood_flash_read32(struct map_info *map, unsigned long ofs)
 {
-        return *(volatile unsigned int *)(map->map_priv_1 + ofs);
+	return *(volatile unsigned int *)(map->map_priv_1 + ofs);
 }
 
 void redwood_flash_copy_from(struct map_info *map, void *to,
-                             unsigned long from, ssize_t len)
+		unsigned long from, ssize_t len)
 {
-        memcpy(to, (void *)(map->map_priv_1 + from), len);
+	memcpy(to, (void *)(map->map_priv_1 + from), len);
 }
 
 void redwood_flash_write8(struct map_info *map, __u8 d, unsigned long adr)
 {
-        *(__u8 *)(map->map_priv_1 + adr) = d;
+	*(__u8 *)(map->map_priv_1 + adr) = d;
 }
 
 void redwood_flash_write16(struct map_info *map, __u16 d, unsigned long adr)
 {
-        *(__u16 *)(map->map_priv_1 + adr) = d;
+	*(__u16 *)(map->map_priv_1 + adr) = d;
 }
 
 void redwood_flash_write32(struct map_info *map, __u32 d, unsigned long adr)
 {
-        *(__u32 *)(map->map_priv_1 + adr) = d;
+	*(__u32 *)(map->map_priv_1 + adr) = d;
 }
 
 void redwood_flash_copy_to(struct map_info *map, unsigned long to,
-                           const void *from, ssize_t len)
+		const void *from, ssize_t len)
 {
-        memcpy((void *)(map->map_priv_1 + to), from, len);
+	memcpy((void *)(map->map_priv_1 + to), from, len);
 }
 
 struct map_info redwood_flash_map = {
-        name: "IBM Redwood",
-        size: WINDOW_SIZE,
-        buswidth: 2,
-        read8: redwood_flash_read8,
-        read16: redwood_flash_read16,
-        read32: redwood_flash_read32,
-        copy_from: redwood_flash_copy_from,
-        write8: redwood_flash_write8,
-        write16: redwood_flash_write16,
-        write32: redwood_flash_write32,
-        copy_to: redwood_flash_copy_to
+	name: "IBM Redwood",
+	size: WINDOW_SIZE,
+	buswidth: 2,
+	read8: redwood_flash_read8,
+	read16: redwood_flash_read16,
+	read32: redwood_flash_read32,
+	copy_from: redwood_flash_copy_from,
+	write8: redwood_flash_write8,
+	write16: redwood_flash_write16,
+	write32: redwood_flash_write32,
+	copy_to: redwood_flash_copy_to
 };
 
 
-static struct mtd_partition redwood_flash_partitions[] = {
-        {
-                name: "Redwood OpenBIOS Vital Product Data",
-                offset: 0,
-                size:   0x10000,
-                mask_flags: MTD_WRITEABLE       /* force read-only */
-        },
-        {
-                name: "Redwood kernel",
-                offset: 0x10000,
-                size:   0x200000 - 0x10000
-        },
-        {
-                name: "Redwood OpenBIOS non-volatile storage",
-                offset: 0x200000,
-                size:   0x10000,
-                mask_flags: MTD_WRITEABLE       /* force read-only */
-        },
-        {
-                name: "Redwood filesystem",
-                offset: 0x210000,
-                size:   0x200000 - (0x10000 + 0x20000)
-        },
-        {
-                name: "Redwood OpenBIOS",
-                offset: 0x3e0000,
-                size:   0x20000,
-                mask_flags: MTD_WRITEABLE       /* force read-only */
-        }
-};
 #define NUM_REDWOOD_FLASH_PARTITIONS \
-        (sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0]))
+	(sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0]))
 
 static struct mtd_info *redwood_mtd;
 
 int __init init_redwood_flash(void)
 {
-        printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
-               WINDOW_SIZE, WINDOW_ADDR);
+	printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
+			WINDOW_SIZE, WINDOW_ADDR);
 
-        redwood_flash_map.map_priv_1 =
-                (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
+	redwood_flash_map.map_priv_1 =
+		(unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
 
-        if (!redwood_flash_map.map_priv_1) {
-                printk("init_redwood_flash: failed to ioremap\n");
-                return -EIO;
-        }
-
-        redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map);
-
-        if (redwood_mtd) {
-                redwood_mtd->module = THIS_MODULE;
-                return add_mtd_partitions(redwood_mtd,
-                                          redwood_flash_partitions,
-                                          NUM_REDWOOD_FLASH_PARTITIONS);
-        }
+	if (!redwood_flash_map.map_priv_1) {
+		printk("init_redwood_flash: failed to ioremap\n");
+		return -EIO;
+	}
+
+	redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map);
+
+	if (redwood_mtd) {
+		redwood_mtd->module = THIS_MODULE;
+		return add_mtd_partitions(redwood_mtd,
+				redwood_flash_partitions,
+				NUM_REDWOOD_FLASH_PARTITIONS);
+	}
 
-        return -ENXIO;
+	return -ENXIO;
 }
 
 static void __exit cleanup_redwood_flash(void)
 {
-        if (redwood_mtd) {
-                del_mtd_partitions(redwood_mtd);
-                iounmap((void *)redwood_flash_map.map_priv_1);
-                map_destroy(redwood_mtd);
-        }
+	if (redwood_mtd) {
+		del_mtd_partitions(redwood_mtd);
+		/* moved iounmap after map_destroy - armin */
+		map_destroy(redwood_mtd);
+		iounmap((void *)redwood_flash_map.map_priv_1);
+	}
 }
 
 module_init(init_redwood_flash);
 module_exit(cleanup_redwood_flash);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Armin Kuster <akuster@mvista.com>");
+MODULE_DESCRIPTION("MTD map driver for the IBM Redwood reference boards");


From trini at infradead.org  Tue Apr  1 13:00:49 2003
From: trini at infradead.org (trini@infradead.org)
Date: Mon May 15 21:48:05 2006
Subject: mtd/drivers/mtd/maps Kconfig,1.3,1.4
Message-ID: <E190Q41-0005eD-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv21701/drivers/mtd/maps

Modified Files:
	Kconfig 
Log Message:
Tighten up the dependancies on PPC32 specific maps.


Index: Kconfig
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/Kconfig,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Kconfig	18 Feb 2003 20:53:53 -0000	1.3
+++ Kconfig	1 Apr 2003 18:00:46 -0000	1.4
@@ -150,7 +150,7 @@
 
 config MTD_TQM8XXL
 	tristate "CFI Flash device mapped on TQM8XXL"
-	depends on MTD_CFI && TQM8xxL && PPC
+	depends on MTD_CFI && PPC32 && 8xx && TQM8xxL
 	help
 	  The TQM8xxL PowerPC board has up to two banks of CFI-compliant
 	  chips, currently uses AMD one. This 'mapping' driver supports
@@ -160,7 +160,7 @@
 
 config MTD_RPXLITE
 	tristate "CFI Flash device mapped on RPX Lite or CLLF"
-	depends on MTD_CFI && 8xx && PPC
+	depends on MTD_CFI && PPC32 && 8xx && (RPXCLASSIC || RPXLITE)
 	help
 	  The RPXLite PowerPC board has CFI-compliant chips mapped in
 	  a strange sparse mapping. This 'mapping' driver supports that
@@ -170,7 +170,7 @@
 
 config MTD_MBX860
 	tristate "System flash on MBX860 board"
-	depends on PPC32 && 8xx && MTD_CFI
+	depends on MTD_CFI && PPC32 && 8xx && MBX860
 	help
 	  This enables access routines for the flash chips on the Motorola
 	  MBX860 board. If you have one of these boards and would like
@@ -193,7 +193,7 @@
 
 config MTD_BEECH
 	tristate "CFI Flash device mapped on IBM 405LP Beech"
-	depends on PPC32 && 40x && MTD_CFI
+	depends on MTD_CFI && PPC32 && 40x && BEECH
 	help
 	  This enables access routines for the flash chips on the IBM
 	  405LP Beech board. If you have one of these boards and would like
@@ -201,7 +201,7 @@
 
 config MTD_ARCTIC
 	tristate "CFI Flash device mapped on IBM 405LP Arctic"
-	depends on PPC32 && 40x && MTD_CFI
+	depends on MTD_CFI && PPC32 && 40x && ARCTIC2
 	help
 	  This enables access routines for the flash chips on the IBM 405LP
 	  Arctic board. If you have one of these boards and would like to
@@ -209,7 +209,7 @@
 
 config MTD_EBONY
 	tristate "CFI Flash device mapped on IBM 440GP Ebony"
-	depends on PPC32 && 440 & MTD_CFI
+	depends on MTD_CFI && PPC32 && 440 && EBONY
 	help
 	  This enables access routines for the flash chips on the IBM 440GP
 	  Ebony board. If you have one of these boards and would like to


From gleixner at infradead.org  Wed Apr  2 11:58:09 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:05 2006
Subject: mtd/util eraseall.c,1.8,1.9
Message-ID: <E190lYv-00008T-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv512

Modified Files:
	eraseall.c 
Log Message:
fix cleanmarker node length for NAND

Index: eraseall.c
===================================================================
RCS file: /home/cvs/mtd/util/eraseall.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- eraseall.c	18 Feb 2003 09:04:51 -0000	1.8
+++ eraseall.c	2 Apr 2003 16:58:06 -0000	1.9
@@ -114,6 +114,7 @@
 			oob.start = erase.start;
 			oob.start += meminfo.oobsize == 16 ? 8 : 6;
 			oob.length = meminfo.oobsize == 16 ? 8 : 2;
+			cleanmarker.totlen = 8; /* NAND code expects this to be 8 ! */
 			if (ioctl (fd, MEMWRITEOOB, &oob) != 0) {
 				fprintf(stderr, "\n%s: %s: MTD writeoob failure: %s\n", exe_name, mtd_device, strerror(errno));
 				continue;


From gleixner at infradead.org  Wed Apr  2 12:00:54 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:05 2006
Subject: mtd/util eraseall.c,1.9,1.10
Message-ID: <E190lba-00008y-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv541

Modified Files:
	eraseall.c 
Log Message:
fix it really. tglx blames himself

Index: eraseall.c
===================================================================
RCS file: /home/cvs/mtd/util/eraseall.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- eraseall.c	2 Apr 2003 16:58:06 -0000	1.9
+++ eraseall.c	2 Apr 2003 17:00:51 -0000	1.10
@@ -78,16 +78,19 @@
 		exit(1);
 	}
 
+	erase.length = meminfo.erasesize;
+	isNAND = meminfo.type == MTD_NANDFLASH ? 1 : 0;
+
 	if (jffs2) {
 		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));
+		if (!isNAND)
+			cleanmarker.totlen = cpu_to_je32 (sizeof (struct jffs2_unknown_node));
+		else
+			cleanmarker.totlen = cpu_to_je32(8); /* NAND code expects this to be 8 ! */
 		cleanmarker.hdr_crc =  cpu_to_je32 (crc32 (0, &cleanmarker,  sizeof (struct jffs2_unknown_node) - 4));
 	}
 
-	erase.length = meminfo.erasesize;
-	isNAND = meminfo.type == MTD_NANDFLASH ? 1 : 0;
-
 	for (erase.start = 0; erase.start < meminfo.size; erase.start += meminfo.erasesize) {
 
 		if (!quiet) {
@@ -114,7 +117,6 @@
 			oob.start = erase.start;
 			oob.start += meminfo.oobsize == 16 ? 8 : 6;
 			oob.length = meminfo.oobsize == 16 ? 8 : 2;
-			cleanmarker.totlen = 8; /* NAND code expects this to be 8 ! */
 			if (ioctl (fd, MEMWRITEOOB, &oob) != 0) {
 				fprintf(stderr, "\n%s: %s: MTD writeoob failure: %s\n", exe_name, mtd_device, strerror(errno));
 				continue;


From trini at infradead.org  Wed Apr  2 13:57:18 2003
From: trini at infradead.org (trini@infradead.org)
Date: Mon May 15 21:48:05 2006
Subject: mtd/drivers/mtd/maps arctic-mtd.c,1.3,1.4
Message-ID: <E190nQE-0000Sr-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv1764/drivers/mtd/maps

Modified Files:
	arctic-mtd.c 
Log Message:
Update the map for the IBM Arctic II so that the kernel and
firmware are on separate partitions.  From Todd Poynor <tpoynor@mvista.com>


Index: arctic-mtd.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/arctic-mtd.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- arctic-mtd.c	31 Jan 2003 08:27:38 -0000	1.3
+++ arctic-mtd.c	2 Apr 2003 18:57:15 -0000	1.4
@@ -43,7 +43,14 @@
 #include <asm/io.h>
 #include <asm/ibm4xx.h>
 
-#define ARCTIC_FFS_SIZE	0x1a00000 /* 26 M */
+/*
+ * fe000000 -- ff9fffff  Arctic FFS (26MB)
+ * ffa00000 -- fff5ffff  kernel (5.504MB)
+ * fff60000 -- ffffffff  firmware (640KB)
+ */
+
+#define ARCTIC_FFS_SIZE		0x01a00000 /* 26 M */
+#define ARCTIC_FIRMWARE_SIZE	0x000a0000 /* 640K */
 
 #define NAME     "Arctic Linux Flash"
 #define PADDR    SUBZERO_BOOTFLASH_PADDR
@@ -132,13 +139,17 @@
 
 static struct mtd_info *arctic_mtd;
 
-static struct mtd_partition arctic_partitions[2] = {
+static struct mtd_partition arctic_partitions[3] = {
 	{ .name		= "Arctic FFS",
 	  .size		= ARCTIC_FFS_SIZE,
 	  .offset	= 0,},
-	{ .name		= "Kernel & firmware",
-	  .size		= (SUBZERO_BOOTFLASH_SIZE - ARCTIC_FFS_SIZE),
+	{ .name		= "Kernel",
+	  .size		= SUBZERO_BOOTFLASH_SIZE - ARCTIC_FFS_SIZE -
+	  		  ARCTIC_FIRMWARE_SIZE,
 	  .offset	= ARCTIC_FFS_SIZE,},
+	{ .name		= "Firmware",
+	  .size		= ARCTIC_FIRMWARE_SIZE,
+	  .offset	= SUBZERO_BOOTFLASH_SIZE - ARCTIC_FIRMWARE_SIZE,},
 };
 
 static int __init
@@ -161,7 +172,7 @@
 
 	arctic_mtd->module = THIS_MODULE;
 
-	return add_mtd_partitions(arctic_mtd, arctic_partitions, 2);
+	return add_mtd_partitions(arctic_mtd, arctic_partitions, 3);
 }
 
 static void __exit


From dwmw2 at infradead.org  Thu Apr  3 06:42:59 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:06 2006
Subject: mtd/util eraseall.c,1.10,1.11
Message-ID: <E19137T-0002Y0-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv9773

Modified Files:
	eraseall.c 
Log Message:
From:Â 	Stephane Fillod <f4cfe@free.fr>
* typo in eraseall.c, enable short option 'j', make cleanmarker to work:
Â  this was obviously NOT tested. Now, it's okay.


Index: eraseall.c
===================================================================
RCS file: /home/cvs/mtd/util/eraseall.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- eraseall.c	2 Apr 2003 17:00:51 -0000	1.10
+++ eraseall.c	3 Apr 2003 11:42:56 -0000	1.11
@@ -45,7 +45,7 @@
 #include "linux/jffs2.h"
 
 #define PROGRAM "eraseall"
-#define VERSION "0.1.1"
+#define VERSION "0.1.2"
 
 static const char *exe_name;
 static const char *mtd_device;
@@ -122,18 +122,20 @@
 				continue;
 			}
 		} else {
-			if (lseek (fd, erase.start, SEEK_SET) != 0) {
+			if (lseek (fd, erase.start, SEEK_SET) < 0) {
 				fprintf(stderr, "\n%s: %s: MTD lseek failure: %s\n", exe_name, mtd_device, strerror(errno));
 				continue;
 			}	
-			if (write (fd , &cleanmarker, sizeof (cleanmarker)) != 0) {
+			if (write (fd , &cleanmarker, sizeof (cleanmarker)) != sizeof (cleanmarker)) {
 				fprintf(stderr, "\n%s: %s: MTD write failure: %s\n", exe_name, mtd_device, strerror(errno));
 				continue;
 			}
 		}
 		if (!quiet)
-			printf ("\rCleanmarker written at %x\n", erase.start);
+			printf (" Cleanmarker written at %x.", erase.start);
 	}
+	if (!quiet)
+		printf("\n");
 
 	return 0;
 }
@@ -147,7 +149,7 @@
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "q";
+		static const char *short_options = "jq";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
@@ -205,7 +207,7 @@
 	printf("Usage: %s [OPTION] MTD_DEVICE\n"
 	       "Erases all of the specified MTD device.\n"
 	       "\n"
-	       "  -j, --jffs2    format the device for jffs2"
+	       "  -j, --jffs2    format the device for jffs2\n"
 	       "  -q, --quiet    don't display progress messages\n"
 	       "      --silent   same as --quiet\n"
 	       "      --help     display this help and exit\n"


From dwmw2 at infradead.org  Thu Apr  3 06:43:40 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:06 2006
Subject: mtd/util fcp.c,1.1,1.2
Message-ID: <E191388-0002YU-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv9803

Modified Files:
	fcp.c 
Log Message:
From:Â 	Stephane Fillod <f4cfe@free.fr>	
* getopt'ified fcp.c, fixes a bug with "fcp -h"


Index: fcp.c
===================================================================
RCS file: /home/cvs/mtd/util/fcp.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fcp.c	18 Jun 2001 10:47:25 -0000	1.1
+++ fcp.c	3 Apr 2003 11:43:37 -0000	1.2
@@ -40,6 +40,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <linux/mtd/mtd.h>
+#include <getopt.h>
 
 typedef int bool;
 #define true 1
@@ -175,40 +176,49 @@
 
    (progname = strrchr (argv[0],'/')) ? progname++ : (progname = argv[0]);
 
-   /*************************************
-	* parse cmd-line args back to front *
-	*************************************/
+   /*********************
+	* parse cmd-line 
+	*****************/
+
+   for (;;) {
+   	int option_index = 0;
+   	static const char *short_options = "hv";
+   	static const struct option long_options[] = {
+   		{"help", no_argument, 0, 'h'},
+   		{"verbose", no_argument, 0, 'v'},
+   		{0, 0, 0, 0},
+   	};
+
+   	int c = getopt_long(argc, argv, short_options,
+   			    long_options, &option_index);
+   	if (c == EOF) {
+   		break;
+   	}
+
+   	switch (c) {
+   	case 'h':
+		flags |= FLAG_HELP;
+		DEBUG("Got FLAG_HELP\n");
+   		break;
+   	case 'v':
+		flags |= FLAG_VERBOSE;
+		DEBUG("Got FLAG_VERBOSE\n");
+		break;
+	default:
+		DEBUG("Unknown parameter: %s\n",argv[option_index]);
+		showusage (progname,true);
+   	}
+   }
+   if (optind+2 == argc) {
+	flags |= FLAG_FILENAME;
+   	filename = argv[optind];
+	DEBUG("Got filename: %s\n",filename);
+
+	flags |= FLAG_DEVICE;
+   	device = argv[optind+1];
+	DEBUG("Got device: %s\n",device);
+   }
 
-   while (--argc)
-	 {
-		if (device == NULL)
-		  {
-			 flags |= FLAG_DEVICE;
-			 device = argv[argc];
-			 DEBUG("Got device: %s\n",device);
-		  }
-		else if (filename == NULL)
-		  {
-			 flags |= FLAG_FILENAME;
-			 filename = argv[argc];
-			 DEBUG("Got filename: %s\n",filename);
-		  }
-		else if (!strcmp (argv[argc],"-v") || !strcmp (argv[argc],"--verbose"))
-		  {
-			 flags |= FLAG_VERBOSE;
-			 DEBUG("Got FLAG_VERBOSE\n");
-		  }
-		else if (!strcmp (argv[argc],"-h") || !strcmp (argv[argc],"--help"))
-		  {
-			 flags |= FLAG_HELP;
-			 DEBUG("Got FLAG_HELP\n");
-		  }
-		else
-		  {
-			 DEBUG("Unknown parameter: %s\n",argv[argc]);
-			 showusage (progname,true);
-		  }
-	 }
    if (flags & FLAG_HELP || progname == NULL || device == NULL)
 	 showusage (progname,flags != FLAG_HELP);
 


From dwmw2 at infradead.org  Thu Apr  3 06:49:25 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:06 2006
Subject: mtd/util mkfs.jffs2.c,1.35,1.36
Message-ID: <E1913Dh-0002a9-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv9906

Modified Files:
	mkfs.jffs2.c 
Log Message:
fix cpu_to_je16() et al w.r.t. args with sideeffects

Index: mkfs.jffs2.c
===================================================================
RCS file: /home/cvs/mtd/util/mkfs.jffs2.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- mkfs.jffs2.c	15 Feb 2003 00:08:10 -0000	1.35
+++ mkfs.jffs2.c	3 Apr 2003 11:49:22 -0000	1.36
@@ -651,8 +651,9 @@
 #undef je16_to_cpu
 #undef je32_to_cpu
 #undef jemode_to_cpu
-#define t16(x) ( (target_endian==__BYTE_ORDER)?x:bswap_16(x) )
-#define t32(x) ( (target_endian==__BYTE_ORDER)?x:bswap_32(x) )
+
+#define t16(x) ({ uint16_t b = x; (target_endian==__BYTE_ORDER)?x:bswap_16(b); })
+#define t32(x) ({ uint32_t b = x; (target_endian==__BYTE_ORDER)?x:bswap_32(b); })
 
 #define cpu_to_je16(x) ((jint16_t){t16(x)})
 #define cpu_to_je32(x) ((jint32_t){t32(x)})


From dwmw2 at infradead.org  Thu Apr  3 06:50:46 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:06 2006
Subject: mtd/util mtd_debug.c,1.3,1.4
Message-ID: <E1913F0-0002b9-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv9968

Modified Files:
	mtd_debug.c 
Log Message:
From:Â 	Stephane Fillod <f4cfe@free.fr>
* gcc-3.x warning cleanups in mtd_debug.c


Index: mtd_debug.c
===================================================================
RCS file: /home/cvs/mtd/util/mtd_debug.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- mtd_debug.c	10 Jan 2002 14:16:58 -0000	1.3
+++ mtd_debug.c	3 Apr 2003 11:50:43 -0000	1.4
@@ -124,10 +124,10 @@
    if ((buf = (u_int8_t *) malloc (size)) == NULL)
 	 {
 #define BUF_SIZE	(64 * 1024 * sizeof (u_int8_t))
-		fprintf (stderr, __FUNCTION__ ": malloc(%#x)\n", size);
+		fprintf (stderr, "%s: malloc(%#x)\n", __FUNCTION__, size);
 		if (size != BUF_SIZE) {
 			size = BUF_SIZE;
-			fprintf (stderr, __FUNCTION__ ": trying buffer size %#x\n", size);
+			fprintf (stderr, "%s: trying buffer size %#x\n", __FUNCTION__, size);
 			goto retry;
 		}
 		perror ("malloc()");
@@ -139,14 +139,14 @@
    err = read (fd,buf,size);
    if (err < 0)
 	 {
-		fprintf (stderr, __FUNCTION__ ": read, size %#x, n %#x\n", size, n);
+		fprintf (stderr, "%s: read, size %#x, n %#x\n", __FUNCTION__, size, n);
 		perror ("read()");
 		goto err2;
 	 }
    err = write (outfd,buf,size);
    if (err < 0)
 	 {
-		fprintf (stderr, __FUNCTION__ ": write, size %#x, n %#x\n", size, n);
+		fprintf (stderr, "%s: write, size %#x, n %#x\n", __FUNCTION__, size, n);
 		perror ("write()");
 		goto err2;
 	 }
@@ -194,10 +194,10 @@
 retry:
    if ((buf = (u_int8_t *) malloc (size)) == NULL)
 	 {
-		fprintf (stderr, __FUNCTION__ ": malloc(%#x) failed\n", size);
+		fprintf (stderr, "%s: malloc(%#x) failed\n", __FUNCTION__, size);
 		if (size != BUF_SIZE) {
 			size = BUF_SIZE;
-			fprintf (stderr, __FUNCTION__ ": trying buffer size %#x\n", size);
+			fprintf (stderr, "%s: trying buffer size %#x\n", __FUNCTION__, size);
 			goto retry;
 		}
 		perror ("malloc()");
@@ -209,7 +209,7 @@
 	   size = n;
    if (fread (buf,size,1,fp) != 1 || ferror (fp))
 	 {
-		fprintf (stderr, __FUNCTION__ ": fread, size %#x, n %#x\n", size, n);
+		fprintf (stderr, "%s: fread, size %#x, n %#x\n", __FUNCTION__, size, n);
 		perror ("fread()");
 		free (buf);
 		fclose (fp);
@@ -218,7 +218,7 @@
    err = write (fd,buf,size);
    if (err < 0)
 	 {
-		fprintf (stderr, __FUNCTION__ ": write, size %#x, n %#x\n", size, n);
+		fprintf (stderr, "%s: write, size %#x, n %#x\n", __FUNCTION__, size, n);
 		perror ("write()");
 		free (buf);
 		fclose (fp);
@@ -298,7 +298,7 @@
 	 printf ("MTD_WRITEABLE");
    else
 	 {
-		int i,first = 1;
+		int first = 1;
 		static struct
 		  {
 			 const char *name;


From dwmw2 at infradead.org  Tue Apr  8 04:20:04 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:06 2006
Subject: mtd/fs/jffs2 nodelist.c,1.78,1.79
Message-ID: <E192oKq-000370-00@phoenix.infradead.org>

Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv11938

Modified Files:
	nodelist.c 
Log Message:
Fix the node sanity checks for device nodes, which have offset+dsize > isize


Index: nodelist.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- nodelist.c	28 Mar 2003 14:52:12 -0000	1.78
+++ nodelist.c	8 Apr 2003 08:20:01 -0000	1.79
@@ -259,7 +259,7 @@
 				}
 				
 				/* sanity checks */
-				if ( je32_to_cpu(node.i.offset) + je32_to_cpu(node.i.dsize) > je32_to_cpu(node.i.isize) ||
+				if ( je32_to_cpu(node.i.offset) > je32_to_cpu(node.i.isize) ||
 				     PAD(je32_to_cpu(node.i.csize) + sizeof (node.i)) != PAD(je32_to_cpu(node.i.totlen))) {
 					printk(KERN_NOTICE "jffs2_get_inode_nodes(): Inode corrupted at 0x%08x, totlen %d, #ino  %d, version %d, isize %d, csize %d, dsize %d \n",
 						ref_offset(ref),  je32_to_cpu(node.i.totlen),  je32_to_cpu(node.i.ino),


From ebiederman at lnxi.com  Tue Apr  8 09:26:08 2003
From: ebiederman at lnxi.com (ebiederman@lnxi.com)
Date: Mon May 15 21:48:06 2006
Subject: mtd/drivers/mtd/maps amd76xrom.c,1.2,1.3
Message-ID: <E192t72-0003pV-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv14692/drivers/mtd/maps

Modified Files:
	amd76xrom.c 
Log Message:
- Add support for the winbond lpc flash w49v002a
- Add support for the amd8111


Index: amd76xrom.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/amd76xrom.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- amd76xrom.c	6 Mar 2003 22:22:37 -0000	1.2
+++ amd76xrom.c	8 Apr 2003 13:26:06 -0000	1.3
@@ -215,6 +215,7 @@
 		PCI_ANY_ID, PCI_ANY_ID, },
 	{ PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7440,  
 		PCI_ANY_ID, PCI_ANY_ID, },
+	{ PCI_VENDOR_ID_AMD, 0x7468 }, /* amd8111 support */
 	{ 0, }
 };
 


From ebiederman at lnxi.com  Tue Apr  8 09:26:08 2003
From: ebiederman at lnxi.com (ebiederman@lnxi.com)
Date: Mon May 15 21:48:06 2006
Subject: mtd/drivers/mtd/chips jedec_probe.c,1.22,1.23
Message-ID: <E192t72-0003pR-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv14692/drivers/mtd/chips

Modified Files:
	jedec_probe.c 
Log Message:
- Add support for the winbond lpc flash w49v002a
- Add support for the amd8111


Index: jedec_probe.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/jedec_probe.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- jedec_probe.c	18 Mar 2003 23:36:28 -0000	1.22
+++ jedec_probe.c	8 Apr 2003 13:26:05 -0000	1.23
@@ -30,6 +30,7 @@
 #define MANUFACTURER_ST		0x0020
 #define MANUFACTURER_SST	0x00BF
 #define MANUFACTURER_TOSHIBA	0x0098
+#define MANUFACTURER_WINBOND	0x00da
 
 
 /* AMD */
@@ -129,6 +130,9 @@
 #define TC58FVT641	0x0093
 #define TC58FVB641	0x0095
 
+/* Winbond */
+#define W49V002A	0x00b0
+
 
 /*
  * Unlock address sets for AMD command sets.
@@ -1050,6 +1054,19 @@
 		NumEraseRegions: 1,
 		regions:         {
 			ERASEINFO( 0x01000, 256 )
+		}
+	} , {
+		mfr_id: MANUFACTURER_WINBOND,
+		dev_id: W49V002A,
+		name: "Winbond W49V002A",
+		uaddr: MTD_UADDR_0x5555_0x2AAA,
+		DevSize: SIZE_256KiB,
+		CmdSet: P_ID_AMD_STD,
+		NumEraseRegions: 4,
+		regions: {ERASEINFO(0x10000, 3),
+			  ERASEINFO(0x08000, 1),
+			  ERASEINFO(0x02000, 2),
+			  ERASEINFO(0x04000, 1),
 		}
 	} 
 };


From dwmw2 at infradead.org  Thu Apr 10 08:20:22 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:06 2006
Subject: mtd/drivers/mtd/maps lubbock-flash.c,NONE,1.1 Config.in,1.45,1.46
 Makefile,1.38,1.39 Kconfig,1.4,1.5
Message-ID: <E193b2U-0004nn-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv18435

Modified Files:
	Config.in Makefile Kconfig 
Added Files:
	lubbock-flash.c 
Log Message:
Add Lubbock map driver.


***** Error reading new file: [Errno 2] No such file or directory: 'lubbock-flash.c'
Index: Config.in
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/Config.in,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- Config.in	1 Apr 2003 02:13:20 -0000	1.45
+++ Config.in	10 Apr 2003 12:20:18 -0000	1.46
@@ -100,6 +100,7 @@
    dep_tristate '  CFI Flash device mapped on StrongARM SA11x0' CONFIG_MTD_SA1100 $CONFIG_MTD_CFI $CONFIG_ARCH_SA1100 $CONFIG_MTD_PARTITIONS
    dep_tristate '  CFI Flash device mapped on DC21285 Footbridge' CONFIG_MTD_DC21285 $CONFIG_MTD_CFI $CONFIG_ARCH_FOOTBRIDGE
    dep_tristate '  CFI Flash device mapped on the XScale IQ80310 board' CONFIG_MTD_IQ80310 $CONFIG_MTD_CFI $CONFIG_ARCH_IQ80310
+   dep_tristate '  CFI Flash device mapped on the XScale Lubbock board' CONFIG_MTD_LUBBOCK $CONFIG_MTD_CFI $CONFIG_ARCH_LUBBOCK
    dep_tristate '  CFI Flash device mapped on Epxa10db' CONFIG_MTD_EPXA10DB $CONFIG_MTD_CFI  $CONFIG_MTD_PARTITIONS $CONFIG_ARCH_CAMELOT
    dep_tristate '  CFI Flash device mapped on the FortuNet board' CONFIG_MTD_FORTUNET $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_SA1100_FORTUNET
    dep_tristate '  NV-RAM mapping AUTCPU12 board' CONFIG_MTD_AUTCPU12 $CONFIG_ARCH_AUTCPU12

Index: Makefile
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/Makefile,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- Makefile	30 Jan 2003 08:45:04 -0000	1.38
+++ Makefile	10 Apr 2003 12:20:18 -0000	1.39
@@ -23,6 +23,7 @@
 obj-$(CONFIG_MTD_AMD76XROM)	+= amd76xrom.o
 obj-$(CONFIG_MTD_ICH2ROM)	+= ich2rom.o
 obj-$(CONFIG_MTD_TSUNAMI)	+= tsunami_flash.o
+obj-$(CONFIG_MTD_LUBBOCK)	+= lubbock-flash.o
 obj-$(CONFIG_MTD_MBX860)	+= mbx860.o
 obj-$(CONFIG_MTD_NORA)		+= nora.o
 obj-$(CONFIG_MTD_CEIVA)		+= ceiva.o

Index: Kconfig
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/Kconfig,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Kconfig	1 Apr 2003 18:00:46 -0000	1.4
+++ Kconfig	10 Apr 2003 12:20:19 -0000	1.5
@@ -99,6 +99,13 @@
 	  devices. This board utilizes Intel StrataFlash. More info at
 	  <http://www.arcomcontrols.com/products/icp/pc104/processors/>.
 
+config MTD_LUBBOCK
+	tristate "CFI Flash device mapped on Intel Lubbock XScale eval board"
+	depends on ARCH_LUBBOCK && MTD_CFI_INTELEXT && MTD_PARTITIONS
+	help
+	  This provides a driver for the on-board flash of the Intel
+	  'Lubbock' XScale evaluation board.
+
 config MTD_MIXMEM
 	tristate "JEDEC Flash device mapped on Mixcom piggyback card"
 	depends on X86 && MTD_JEDEC


From gleixner at infradead.org  Fri Apr 11 07:15:37 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:06 2006
Subject: mtd/drivers/mtd/maps dbox2-flash.c,1.4,1.5
Message-ID: <E193wVN-0000Lt-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv1344

Modified Files:
	dbox2-flash.c 
Log Message:
Update to current state, use C99 initializers. Provided by Alexander Wild.

Index: dbox2-flash.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/dbox2-flash.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- dbox2-flash.c	2 Oct 2001 15:05:14 -0000	1.4
+++ dbox2-flash.c	11 Apr 2003 11:15:34 -0000	1.5
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Nokia / Sagem D-Box 2 flash driver
+ * D-Box 2 flash driver
  */
 
 #include <linux/module.h>
@@ -16,22 +16,44 @@
 /* partition_info gives details on the logical partitions that the split the
  * single flash device into. If the size if zero we use up to the end of the
  * device. */
-static struct mtd_partition partition_info[]= {{name: "BR bootloader",		// raw
-						      size: 128 * 1024, 
-						      offset: 0,                  
-						      mask_flags: MTD_WRITEABLE},
-                                                     {name: "PPC bootloader",		// flfs
-						      size: 128 * 1024, 
-						      offset: MTDPART_OFS_APPEND, 
-						      mask_flags: 0},
-                                                     {name: "Kernel",			// idxfs
-						      size: 768 * 1024, 
-						      offset: MTDPART_OFS_APPEND, 
-						      mask_flags: 0},
-                                                     {name: "System",			// jffs
-						      size: MTDPART_SIZ_FULL, 
-						      offset: MTDPART_OFS_APPEND, 
-						      mask_flags: 0}};
+static struct mtd_partition partition_info[]= {
+	{
+	.name		= "BR bootloader",
+	.size		= 128 * 1024, 
+	.offset		= 0,                  
+	.mask_flags	= MTD_WRITEABLE
+	},
+	{
+	.name		= "flfs (ppcboot)",
+	.size		= 128 * 1024, 
+	.offset		= MTDPART_OFS_APPEND, 
+	.mask_flags	= 0
+	},
+	{
+	.name		= "root (cramfs)",	
+	.size		= 7040 * 1024, 
+	.offset		= MTDPART_OFS_APPEND, 
+	.mask_flags	= 0
+	},
+	{
+	.name		= "var (jffs2)",
+	.size		= 896 * 1024, 
+	.offset		= MTDPART_OFS_APPEND, 
+	.mask_flags	= 0
+	},
+	{
+	.name		= "flash without bootloader",	
+	.size		= MTDPART_SIZ_FULL, 
+	.offset		= 128 * 1024, 
+	.mask_flags	= 0
+	},
+	{
+	.name		= "complete flash",	
+	.size		= MTDPART_SIZ_FULL, 
+	.offset		= 0, 
+	.mask_flags	= MTD_WRITEABLE
+	}
+};
 
 #define NUM_PARTITIONS (sizeof(partition_info) / sizeof(partition_info[0]))
 
@@ -84,17 +106,17 @@
 }
 
 struct map_info dbox2_flash_map = {
-	name: "D-Box 2 flash memory",
-	size: WINDOW_SIZE,
-	buswidth: 4,
-	read8: dbox2_flash_read8,
-	read16: dbox2_flash_read16,
-	read32: dbox2_flash_read32,
-	copy_from: dbox2_flash_copy_from,
-	write8: dbox2_flash_write8,
-	write16: dbox2_flash_write16,
-	write32: dbox2_flash_write32,
-	copy_to: dbox2_flash_copy_to
+	.name		= "D-Box 2 flash memory",
+	.size		= WINDOW_SIZE,
+	.buswidth	= 4,
+	.read8		= dbox2_flash_read8,
+	.read16		= dbox2_flash_read16,
+	.read32		= dbox2_flash_read32,
+	.copy_from	= dbox2_flash_copy_from,
+	.write8		= dbox2_flash_write8,
+	.write16	= dbox2_flash_write16,
+	.write32	= dbox2_flash_write32,
+	.copy_to	= dbox2_flash_copy_to
 };
 
 int __init init_dbox2_flash(void)
@@ -146,5 +168,5 @@
 
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>");
-MODULE_DESCRIPTION("MTD map driver for Nokia/Sagem D-Box 2 board");
+MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>, Bastian Blank <waldi@tuxbox.org>, Alexander Wild <wild@te-elektronik.com>");
+MODULE_DESCRIPTION("MTD map driver for D-Box 2 board");


From tharbaugh at lnxi.com  Fri Apr 11 11:08:29 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:06 2006
Subject: mtd/drivers/mtd/chips jedec_probe.c,1.23,1.24
Message-ID: <E19408j-0000za-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv3805/chips

Modified Files:
	jedec_probe.c 
Log Message:
Order jedec_table[].
Add unlock addresses for all data output widths.
No longer check for ID's in all blocks - just the first one.
Fixed incorrert unlock addresses for some devices (ATMEL? - don' remember).


Index: jedec_probe.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/jedec_probe.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- jedec_probe.c	8 Apr 2003 13:26:05 -0000	1.23
+++ jedec_probe.c	11 Apr 2003 15:08:26 -0000	1.24
@@ -27,8 +27,8 @@
 #define MANUFACTURER_INTEL	0x0089
 #define MANUFACTURER_MACRONIX	0x00C2
 #define MANUFACTURER_PMC	0x009D
-#define MANUFACTURER_ST		0x0020
 #define MANUFACTURER_SST	0x00BF
+#define MANUFACTURER_ST		0x0020
 #define MANUFACTURER_TOSHIBA	0x0098
 #define MANUFACTURER_WINBOND	0x00da
 
@@ -41,7 +41,7 @@
 #define AM29LV160DT	0x22C4
[...1375 lines suppressed...]
+	 * Make sure the ID's dissappear when the device is taken out of
+	 * ID mode.  The only time this should fail when it should succeed
+	 * is when the ID's are written as data to the same
 	 * addresses.  For this rare and unfortunate case the chip
 	 * cannot be probed correctly.
 	 * FIXME - write a driver that takes all of the chip info as
-	 * module parameters.
+	 * module parameters, doesn't probe but forces a load.
 	 */
 	DEBUG( MTD_DEBUG_LEVEL3,
 	       "MTD %s(): check ID's disappear when not in ID mode\n",
@@ -1316,7 +1449,7 @@
 		printk(KERN_INFO "Search for id:(%02x %02x) interleave(%d) type(%d)\n", 
 			cfi->mfr, cfi->id, cfi->interleave, cfi->device_type);
 		for (i=0; i<sizeof(jedec_table)/sizeof(jedec_table[0]); i++) {
-			if ( jedec_match( base, map, cfi, i ) ) {
+			if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) {
 				DEBUG( MTD_DEBUG_LEVEL3,
 				       "MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n",
 				       __func__,


From tharbaugh at lnxi.com  Fri Apr 11 18:25:20 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:06 2006
Subject: mtd/drivers/mtd/chips cfi_cmdset_0002.c,1.65,1.66
Message-ID: <E1946xU-0002ex-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv10212

Modified Files:
	cfi_cmdset_0002.c 
Log Message:
Print error information when status bits can't be decoded.
Cleanup ugly if/else nesting with easier to read goto.

Index: cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- cfi_cmdset_0002.c	28 Mar 2003 19:47:42 -0000	1.65
+++ cfi_cmdset_0002.c	11 Apr 2003 22:25:17 -0000	1.66
@@ -457,7 +457,7 @@
 static int do_write_oneword(struct map_info *map, struct flchip *chip, unsigned long adr, __u32 datum, int fast)
 {
 	unsigned long timeo = jiffies + HZ;
-	unsigned int oldstatus, status;
+	unsigned int oldstatus, status, prev_oldstatus, prev_status;
 	unsigned int dq6, dq5;	
 	struct cfi_private *cfi = map->fldrv_priv;
     /* We use a 1ms + 1 jiffies generic timeout for writes (most devices have
@@ -500,6 +500,7 @@
 
 	adr += chip->start;
 	ENABLE_VPP(map);
+
 	if (fast) { /* Unlock bypass */
 		cfi_send_gen_cmd(0xA0, 0, chip->start, map, cfi, cfi->device_type, NULL);
 	}
@@ -521,24 +522,24 @@
 	 * This ensures that write operation is really completed,
 	 * or tells us why it failed.
 	 *
-	 * The polling and decoding of error state appears that it could
+	 * It appears tha the polling and decoding of error state might
 	 * be simplified.  Don't do it unless you really know what you
 	 * are doing.  You must remember that JESD21-C 3.5.3 states that
 	 * the status must be read back an _additional_ two times before
 	 * a failure is determined.  This is because these devices have
 	 * internal state machines that are asynchronous to the external
-	 * LPC bus.  During an erase or write the read-back status of the
-	 * polling bits might be internaling transitioning when the external
+	 * data bus.  During an erase or write the read-back status of the
+	 * polling bits might be transitioning internaly when the external
 	 * read-back occurs.  This means that the bits aren't in the final
 	 * state and they might appear to report an error as they transition
 	 * and are in a weird state.  This will produce infrequent errors
-	 * that will usually disappear then next time an erase or write
+	 * that will usually disappear the next time an erase or write
 	 * happens (Try tracking those errors down!).  To ensure that
 	 * the bits are not in transition the location must be read-back
 	 * two more times and compared against what was written - BOTH reads
 	 * MUST match what was written - don't think this can be simplified
-	 * to only the last read matching.  If the comparison fails error
-	 * state can then be decoded with certainty.
+	 * to only the last read matching.  If the comparison fails, error
+	 * state can then be decoded.
 	 *
 	 * - Thayne Harbaugh
 	 */
@@ -572,55 +573,82 @@
 		/* dq6 still toggling and dq5 still low - must be timeout */
 		printk( KERN_WARNING
 			"MTD %s(): Timed out while waiting for write to complete.\n",
-			__func__ );        
-		/* reset */
-		cfi_write( map, CMD(0xF0), chip->start );
-		ret = -EIO;
-	} else {
-		/*
-		 * Either dq5 went high or dq6 finish toggling.  For
-		 * the correct completion of certain types of writes
-		 * dq5 might _appear_ to go high while dq6 might
-		 * _appear_ to still be toggling - it depends on the
-		 * last state of the toggle was in and what the final
-		 * state will be with true data.  We alread know that
-		 * something changed state with the last set of reads.
-		 * We will read two more times and use this to either
-		 * verify that the write completed successfully or
-		 * that something really went wrong.  BOTH reads
-		 * must match what was written - this certifies that
-		 * the dq6 is not still toggling and have the status
-		 * bits erroneously match the datum that was written.
-		 */
-		/*
-		 * Be optimistic and check success first - then decode any
-		 * failures.
-		 */
-		oldstatus = cfi_read(map, adr);
-		status = cfi_read(map, adr);
-
-		if ( oldstatus == datum && status == datum ) {
-			/* success - do nothing */
-		} else {
-			/* something has failed */
-			if ( ( ( status ^ oldstatus ) & dq6 )
-			     && ( status & dq5 ) ) {
-				printk(KERN_WARNING "MTD %s(): Internal flash device timeout occured.\n", __func__ );
-			} else {
-				/*
-				 * This state means that the write did not succeed
-				 * and that the usual error state of toggling dq6
-				 * while dq5 goes high did not happen.  Something
-				 * is seriously wacky!
-				 */
-				printk(KERN_WARNING "MTD %s(): Wacky!  Unable to decode failure status\n", __func__ );
-			}
-			ret = -EIO;
-			/* reset on all failures. */
-			cfi_write( map, CMD(0xF0), chip->start );
-		}
+			__func__ );
+		goto write_failed;
 	}
 
+	/*
+	 * Either dq5 went high or dq6 finish toggling.  For
+	 * the correct completion of certain types of writes
+	 * dq5 might _appear_ to go high while dq6 might
+	 * _appear_ to still be toggling - it depends on the
+	 * last toggle-state dq6 was in and what the final
+	 * state will be with true data.  We alread know that
+	 * something changed state with the last set of reads.
+	 * We will read two more times and use this to either
+	 * verify that the write completed successfully or
+	 * that something really went wrong.  BOTH reads
+	 * must match what was written - this certifies that
+	 * dq6 is not still toggling  and that the status
+	 * bits erroneously match the datum that was written.
+	 */
+	prev_oldstatus = oldstatus;
+	prev_status = status;
+
+	/*
+	 * Be optimistic and check success first - then decode any
+	 * failures.
+	 */
+	oldstatus = cfi_read(map, adr);
+	status = cfi_read(map, adr);
+
+	if ( oldstatus == datum && status == datum ) {
+		/* success - do nothing */
+		goto write_done;
+	}
+
+	/* something has failed */
+	if ( ( ( status ^ oldstatus ) & dq6 )
+	     && ( status & dq5 ) ) {
+		printk(KERN_WARNING
+		       "MTD %s(): Internal flash device timeout occured.\n",
+		       __func__ );
+		goto write_failed;
+	}
+
+	/*
+	 * If we get to here then it means that something failed
+	 * and that the usual error state of toggling dq6
+	 * while dq5 goes high did not happen.  Something
+	 * is seriously wacky!  Dump some debug info.
+	 */
+	printk(KERN_WARNING "MTD %s(): Wacky!  Unable to decode failure status\n", __func__ );
+	printk(KERN_WARNING
+	       "MTD %s(): 0x%.2x: 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",
+	       __func__, datum,
+	       prev_oldstatus, prev_status,
+	       oldstatus, status);
+
+	printk(KERN_WARNING "MTD %s(): dq6: %d %d %d %d\n",
+	       __func__,
+	       prev_oldstatus & dq6 ? 1 : 0,
+	       prev_status & dq6 ? 1 : 0,
+	       oldstatus & dq6 ? 1 : 0,
+	       status & dq6 ? 1 : 0);
+
+	printk(KERN_WARNING "MTD %s(): dq5: %d %d %d %d\n",
+	       __func__,
+	       prev_oldstatus & dq5 ? 1 : 0,
+	       prev_status & dq5 ? 1 : 0,
+	       oldstatus & dq5 ? 1 : 0,
+	       status & dq5 ? 1 : 0);
+
+ write_failed:
+	ret = -EIO;
+	/* reset on all failures. */
+	cfi_write( map, CMD(0xF0), chip->start );
+
+ write_done:
 	DISABLE_VPP(map);
 	chip->state = FL_READY;
 	wake_up(&chip->wq);


From gleixner at infradead.org  Mon Apr 14 02:58:07 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:06 2006
Subject: mtd/html/tech nand.html,1.16,1.17
Message-ID: <E194xup-0002wl-00@phoenix.infradead.org>

Update of /home/cvs/mtd/html/tech
In directory phoenix.infradead.org:/tmp/cvs-serv11318

Modified Files:
	nand.html 
Log Message:
add ECC selector in board setup to avoid stupid questions

Index: nand.html
===================================================================
RCS file: /home/cvs/mtd/html/tech/nand.html,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- nand.html	8 Mar 2003 10:34:58 -0000	1.16
+++ nand.html	14 Apr 2003 06:58:04 -0000	1.17
@@ -359,6 +359,8 @@
 line or NULL, if you don't have one</i><br>
 this->chip_delay = 20;<i>The delay time (us), after writing a command to the chip, 
 according to datasheet (tR)</i><br>
+this-&gt;eccmode = NAND_ECC_XXX; <i>Set the correct ECC generator mode for your board. This
+defaults to NAND_ECC_SOFT. Notes about hardware ECC can be found below.<br>
 SNIP<br>
 }</p>
 


From gleixner at infradead.org  Mon Apr 14 03:00:42 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd/nand nand.c,1.42,1.43
Message-ID: <E194xxK-0002xA-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv11343

Modified Files:
	nand.c 
Log Message:
Give warning if ECC_MODE_NONE is selected.

Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- nand.c	20 Feb 2003 13:39:38 -0000	1.42
+++ nand.c	14 Apr 2003 07:00:39 -0000	1.43
@@ -1321,6 +1321,7 @@
 		BUG();	
 
 	case NAND_ECC_NONE: 
+		printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n");
 		this->eccmode = NAND_ECC_NONE;
 		break;
 


From tharbaugh at lnxi.com  Tue Apr 15 18:32:16 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd/chips cfi_cmdset_0002.c,1.66,1.67
Message-ID: <E195YyO-0003Nh-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv12986

Modified Files:
	cfi_cmdset_0002.c 
Log Message:
Error information and status history on all write/erase failures.
Handle interleaved chips correctly (this might change slightly in the
future - see the FIXME note that was added).
Thanks to Alexander Wild for help debugging interleaved chips.


Index: cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- cfi_cmdset_0002.c	11 Apr 2003 22:25:17 -0000	1.66
+++ cfi_cmdset_0002.c	15 Apr 2003 22:32:13 -0000	1.67
@@ -51,6 +51,7 @@
 	module: THIS_MODULE
 };
 
+
 struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
@@ -458,7 +459,7 @@
 {
 	unsigned long timeo = jiffies + HZ;
 	unsigned int oldstatus, status, prev_oldstatus, prev_status;
-	unsigned int dq6, dq5;	
+	unsigned int dq6;
 	struct cfi_private *cfi = map->fldrv_priv;
     /* We use a 1ms + 1 jiffies generic timeout for writes (most devices have
        a max write time of a few hundreds usec). However, we should use the
@@ -499,8 +500,10 @@
 	chip->state = FL_WRITING;
 
 	adr += chip->start;
-	ENABLE_VPP(map);
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): WRITE 0x%.8lx(0x%.8x)\n",
+	       __func__, adr, datum );
 
+	ENABLE_VPP(map);
 	if (fast) { /* Unlock bypass */
 		cfi_send_gen_cmd(0xA0, 0, chip->start, map, cfi, cfi->device_type, NULL);
 	}
@@ -509,8 +512,6 @@
 	        cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
 	        cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
 	}
-
-	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): WRITE 0x%.2x\n", __func__, datum );
 	cfi_write(map, datum, adr);
 
 	cfi_spin_unlock(chip->mutex);
@@ -544,16 +545,38 @@
 	 * - Thayne Harbaugh
 	 */
 	dq6 = CMD(1<<6);
-	dq5 = CMD(1<<5);
 	/* See comment above for timeout value. */
 	timeo = jiffies + uWriteTimeout; 
 		
 	oldstatus = cfi_read(map, adr);
 	status = cfi_read(map, adr);
-	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.2x 0x%.2x\n", __func__, oldstatus, status );
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+	       __func__, oldstatus, status );
 
+	/*
+	 * This assumes that dq5 == dq6 >> 1
+	 * It's done this way so that we only look for asserted dq5
+	 * on interleaved chips that are still toggling - we can
+	 * ignore chips that have already completed and might have
+	 * dq5 asserted.  It is important to use oldstatus because
+	 * a completed state might look like it has toggled from
+	 * the previous read of status bits and it might trigger
+	 * an erroneous error.
+	 *
+	 * FIXME - this is rather complicated - trying to deal with
+	 * asynchronous transitions and cases where the toggle bit
+	 * appears to toggle when it has really just settled to true
+	 * data and having to read the locations an additional two
+	 * times to verify bits.  It might be that we just need
+	 * to watch dq6 and our timeout and ignore dq5.  If the
+	 * timeout is exceeded and we still have dq6 toggling we then
+	 * look for asserted dq5 for each toggling dq6.  That would
+	 * be safer, easier to code and get correct, and marginally
+	 * less efficient.  Who cares if the error case, which should
+	 * be very infrequent, is optimized.
+	 */
 	while( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( status & dq5 )
+	       && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 ) >> 1 )
 	       && ! time_after(jiffies, timeo) ) {
 
 		if (need_resched()) {
@@ -565,11 +588,12 @@
 
 		oldstatus = cfi_read( map, adr );
 		status = cfi_read( map, adr );
-		DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.2x 0x%.2x\n", __func__, oldstatus, status );
+		DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+		       __func__, oldstatus, status );
 	}
 
 	if ( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( status & dq5 ) ) {
+	     && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 ) >> 1 ) ) {
 		/* dq6 still toggling and dq5 still low - must be timeout */
 		printk( KERN_WARNING
 			"MTD %s(): Timed out while waiting for write to complete.\n",
@@ -592,15 +616,17 @@
 	 * dq6 is not still toggling  and that the status
 	 * bits erroneously match the datum that was written.
 	 */
-	prev_oldstatus = oldstatus;
-	prev_status = status;
 
 	/*
 	 * Be optimistic and check success first - then decode any
 	 * failures.
 	 */
+	prev_oldstatus = oldstatus;
+	prev_status = status;
 	oldstatus = cfi_read(map, adr);
 	status = cfi_read(map, adr);
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+	       __func__, oldstatus, status );
 
 	if ( oldstatus == datum && status == datum ) {
 		/* success - do nothing */
@@ -609,40 +635,28 @@
 
 	/* something has failed */
 	if ( ( ( status ^ oldstatus ) & dq6 )
-	     && ( status & dq5 ) ) {
+	     && ( status & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
 		printk(KERN_WARNING
 		       "MTD %s(): Internal flash device timeout occured.\n",
 		       __func__ );
-		goto write_failed;
+	} else {
+		/*
+		 * If we get to here then it means that something failed
+		 * and that the usual error state of toggling dq6
+		 * while dq5 goes high did not happen.  Something
+		 * is seriously wacky!  Dump some debug info.
+		 */
+		printk(KERN_WARNING
+		       "MTD %s(): Wacky!  Unable to decode failure status\n",
+		       __func__ );
 	}
 
-	/*
-	 * If we get to here then it means that something failed
-	 * and that the usual error state of toggling dq6
-	 * while dq5 goes high did not happen.  Something
-	 * is seriously wacky!  Dump some debug info.
-	 */
-	printk(KERN_WARNING "MTD %s(): Wacky!  Unable to decode failure status\n", __func__ );
 	printk(KERN_WARNING
-	       "MTD %s(): 0x%.2x: 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",
-	       __func__, datum,
+	       "MTD %s(): 0x%.8lx(0x%.8x): 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",
+	       __func__, adr, datum,
 	       prev_oldstatus, prev_status,
 	       oldstatus, status);
 
-	printk(KERN_WARNING "MTD %s(): dq6: %d %d %d %d\n",
-	       __func__,
-	       prev_oldstatus & dq6 ? 1 : 0,
-	       prev_status & dq6 ? 1 : 0,
-	       oldstatus & dq6 ? 1 : 0,
-	       status & dq6 ? 1 : 0);
-
-	printk(KERN_WARNING "MTD %s(): dq5: %d %d %d %d\n",
-	       __func__,
-	       prev_oldstatus & dq5 ? 1 : 0,
-	       prev_status & dq5 ? 1 : 0,
-	       oldstatus & dq5 ? 1 : 0,
-	       status & dq5 ? 1 : 0);
-
  write_failed:
 	ret = -EIO;
 	/* reset on all failures. */
@@ -804,13 +818,14 @@
 
 static inline int do_erase_chip(struct map_info *map, struct flchip *chip)
 {
-	unsigned int oldstatus, status;
-	unsigned int dq6, dq5;
+	unsigned int oldstatus, status, prev_oldstatus, prev_status;
+	unsigned int dq6;
 	unsigned long timeo = jiffies + HZ;
-	unsigned int adr;
+	unsigned long int adr;
 	struct cfi_private *cfi = map->fldrv_priv;
-	int ret = 0;
 	DECLARE_WAITQUEUE(wait, current);
+	int ret = 0;
+	__u32 ones = 0;
 
  retry:
 	cfi_spin_lock(chip->mutex);
@@ -833,6 +848,8 @@
 	}	
 
 	chip->state = FL_ERASING;
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n",
+	       __func__, chip->start );
 	
 	/* Handle devices with one erase region, that only implement
 	 * the chip erase command.
@@ -858,12 +875,14 @@
 	 */
 	/* see comments in do_write_oneword */
 	dq6 = CMD(1<<6);
-	dq5 = CMD(1<<5);
 
 	oldstatus = cfi_read(map, adr);
 	status = cfi_read(map, adr);
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+	       __func__, oldstatus, status );
+
 	while( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( status & dq5 )
+	       && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) )
 	       && ! time_after(jiffies, timeo) ) {
 		int wait_reps;
 
@@ -895,7 +914,7 @@
 		for(wait_reps = 0;
 		    (wait_reps < 100)
 			    && ( ( status ^ oldstatus ) & dq6 )
-			    && ! ( status & dq5 );
+			    && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) );
 		    wait_reps++) {
 			
 			/* Latency issues. Drop the lock, wait a while and retry */
@@ -906,63 +925,82 @@
 			cfi_spin_lock(chip->mutex);
 			oldstatus = cfi_read(map, adr);
 			status = cfi_read(map, adr);
+			DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+			       __func__, oldstatus, status );
 		}
 		oldstatus = cfi_read(map, adr);
 		status = cfi_read(map, adr);
+		DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+		       __func__, oldstatus, status );
 	}
 
 	if ( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( status & dq5 ) ) {
+	     && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
 		/* dq6 still toggling and dq5 still low - must be timeout */
 		printk( KERN_WARNING
 			"MTD %s(): Timed out while waiting for erase to complete.\n",
-			__func__ );        
-		/* reset */
-		cfi_write( map, CMD(0xF0), chip->start );
-		ret = -EIO;
-	} else {
-		__u32 ones = 0;
-/*
-		 * Be optimistic and check success first - then decode any
-		 * failures.
-		 */
-		oldstatus = cfi_read(map, adr);
-		status = cfi_read(map, adr);
+			__func__ );
+		goto erase_failed;
+	}
+
+	/*
+	 * Be optimistic and check success first - then decode any
+	 * failures.
+	 */
+	prev_oldstatus = oldstatus;
+	prev_status = status;
+	oldstatus = cfi_read(map, adr);
+	status = cfi_read(map, adr);
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+	       __func__, oldstatus, status );
 		
-		switch( CFIDEV_BUSWIDTH ) {
-		case 1:
-			ones = (__u8)~0;
-			break;
-		case 2:
-			ones = (__u16)~0;
-			break;
-		case 4:
-			ones = (__u32)~0;
-			break;
-		}
+	switch( CFIDEV_BUSWIDTH ) {
+	case 1:
+		ones = (__u8)~0;
+		break;
+	case 2:
+		ones = (__u16)~0;
+		break;
+	case 4:
+		ones = (__u32)~0;
+		break;
+	}
 	
-		if ( oldstatus == ones && status == ones ) {
-			/* success - do nothing */
-		} else {
-			/* something has failed */
-			if ( ( ( status ^ oldstatus ) & dq6 )
-			     && ( status & dq5 ) ) {
-				printk(KERN_WARNING "MTD %s(): Internal flash device timeout occured.\n", __func__ );
-			} else {
-				/*
-				 * This state means that the erase did not succeed
-				 * and that the usual error state of toggling dq6
-				 * while dq5 goes high did not happen.  Something
-				 * is seriously wacky!
-				 */
-				printk(KERN_WARNING "MTD %s(): Wacky!  Unable to decode failure status\n", __func__ );
-			}
-			ret = -EIO;
-			/* reset on all failures. */
-			cfi_write( map, CMD(0xF0), chip->start );
-		}
+	if ( oldstatus == ones && status == ones ) {
+		/* success - do nothing */
+		goto erase_done;
+	}
+
+	/* something has failed */
+	if ( ( ( status ^ oldstatus ) & dq6 )
+	     && ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
+		printk(KERN_WARNING
+		       "MTD %s(): Internal flash device timeout occured.\n",
+		       __func__ );
+	} else {
+		/*
+		 * This state means that the erase did not succeed
+		 * and that the usual error state of toggling dq6
+		 * while dq5 goes high did not happen.  Something
+		 * is seriously wacky!
+		 */
+		printk(KERN_WARNING
+		       "MTD %s(): Wacky!  Unable to decode failure status\n",
+		       __func__ );
 	}
 
+	printk(KERN_WARNING
+	       "MTD %s(): 0x%.8lx(0x%.8x): 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",
+	       __func__, adr, ones,
+	       prev_oldstatus, prev_status,
+	       oldstatus, status);
+
+ erase_failed:
+	ret = -EIO;
+	/* reset on all failures. */
+	cfi_write( map, CMD(0xF0), chip->start );
+
+ erase_done:
 	DISABLE_VPP(map);
 	chip->state = FL_READY;
 	wake_up(&chip->wq);
@@ -970,14 +1008,16 @@
 	return ret;
 }
 
+
 static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, unsigned long adr)
 {
-	unsigned int oldstatus, status;
-	unsigned int dq6, dq5;
+	unsigned int oldstatus, status, prev_oldstatus, prev_status;
+	unsigned int dq6;
 	unsigned long timeo = jiffies + HZ;
 	struct cfi_private *cfi = map->fldrv_priv;
-	int ret = 0;
 	DECLARE_WAITQUEUE(wait, current);
+	int ret = 0;
+	__u32 ones = 0;
 
  retry:
 	cfi_spin_lock(chip->mutex);
@@ -1002,12 +1042,16 @@
 	chip->state = FL_ERASING;
 
 	adr += chip->start;
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n",
+	       __func__, adr );
+
 	ENABLE_VPP(map);
 	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
 	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
 	cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
 	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
 	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, CFI_DEVICETYPE_X8, NULL);
+
 	cfi_write(map, CMD(0x30), adr);
 	
 	timeo = jiffies + (HZ*20);
@@ -1023,12 +1067,14 @@
 	 */
 	/* see comments in do_write_oneword */
 	dq6 = CMD(1<<6);
-	dq5 = CMD(1<<5);
 
 	oldstatus = cfi_read(map, adr);
 	status = cfi_read(map, adr);
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+	       __func__, oldstatus, status );
+
 	while( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( status & dq5 )
+	       && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) )
 	       && ! time_after(jiffies, timeo) ) {
 		int wait_reps;
 
@@ -1060,7 +1106,7 @@
 		for(wait_reps = 0;
 		    (wait_reps < 100)
 			    && ( ( status ^ oldstatus ) & dq6 )
-			    && ! ( status & dq5 );
+			    && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) );
 		    wait_reps++) {
 			
 			/* Latency issues. Drop the lock, wait a while and retry */
@@ -1071,64 +1117,82 @@
 			cfi_spin_lock(chip->mutex);
 			oldstatus = cfi_read(map, adr);
 			status = cfi_read(map, adr);
+			DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+			       __func__, oldstatus, status );
 		}
 		oldstatus = cfi_read(map, adr);
 		status = cfi_read(map, adr);
+		DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+		       __func__, oldstatus, status );
 	}
 
 	if ( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( status & dq5 ) ) {
+	     && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
 		/* dq6 still toggling and dq5 still low - must be timeout */
 		printk( KERN_WARNING
 			"MTD %s(): Timed out while waiting for erase to complete.\n",
-			__func__ );        
-		/* reset */
-		cfi_write( map, CMD(0xF0), chip->start );
-		ret = -EIO;
-	} else {
-		__u32 ones = 0;
+			__func__ );
+		goto erase_failed;
+	}
 
-		/*
-		 * Be optimistic and check success first - then decode any
-		 * failures.
-		 */
-		oldstatus = cfi_read(map, adr);
-		status = cfi_read(map, adr);
+	/*
+	 * Be optimistic and check success first - then decode any
+	 * failures.
+	 */
+	prev_oldstatus = oldstatus;
+	prev_status = status;
+	oldstatus = cfi_read(map, adr);
+	status = cfi_read(map, adr);
+	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
+	       __func__, oldstatus, status );
 
-		switch( CFIDEV_BUSWIDTH ) {
-		case 1:
-			ones = (__u8)~0;
-			break;
-		case 2:
-			ones = (__u16)~0;
-			break;
-		case 4:
-			ones = (__u32)~0;
-			break;
-		}
+	switch( CFIDEV_BUSWIDTH ) {
+	case 1:
+		ones = (__u8)~0;
+		break;
+	case 2:
+		ones = (__u16)~0;
+		break;
+	case 4:
+		ones = (__u32)~0;
+		break;
+	}
 	
-		if ( oldstatus == ones && status == ones ) {
-			/* success - do nothing */
-		} else {
-			/* something has failed */
-			if ( ( ( status ^ oldstatus ) & dq6 )
-			     && ( status & dq5 ) ) {
-				printk(KERN_WARNING "MTD %s(): Internal flash device timeout occured.\n", __func__ );
-			} else {
-				/*
-				 * This state means that the erase did not succeed
-				 * and that the usual error state of toggling dq6
-				 * while dq5 goes high did not happen.  Something
-				 * is seriously wacky!
-				 */
-				printk(KERN_WARNING "MTD %s(): Wacky!  Unable to decode failure status\n", __func__ );
-			}
-			ret = -EIO;
-			/* reset on all failures. */
-			cfi_write( map, CMD(0xF0), chip->start );
-		}
+	if ( oldstatus == ones && status == ones ) {
+		/* success - do nothing */
+		goto erase_done;
 	}
 
+	/* something has failed */
+	if ( ( ( status ^ oldstatus ) & dq6 )
+	     && ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
+		printk(KERN_WARNING
+		       "MTD %s(): Internal flash device timeout occured.\n",
+		       __func__ );
+	} else {
+		/*
+		 * This state means that the erase did not succeed
+		 * and that the usual error state of toggling dq6
+		 * while dq5 goes high did not happen.  Something
+		 * is seriously wacky!
+		 */
+		printk(KERN_WARNING
+		       "MTD %s(): Wacky!  Unable to decode failure status\n",
+		       __func__ );
+	}
+
+	printk(KERN_WARNING
+	       "MTD %s(): 0x%.8lx(0x%.8x): 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",
+	       __func__, adr, ones,
+	       prev_oldstatus, prev_status,
+	       oldstatus, status);
+
+ erase_failed:
+	ret = -EIO;
+	/* reset on all failures. */
+	cfi_write( map, CMD(0xF0), chip->start );
+
+ erase_done:
 	DISABLE_VPP(map);
 	chip->state = FL_READY;
 	wake_up(&chip->wq);


From tharbaugh at lnxi.com  Wed Apr 16 12:09:29 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd/devices .cvsignore,NONE,1.1
Message-ID: <E195pTV-000782-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/devices
In directory phoenix.infradead.org:/tmp/cvs-serv27376/devices

Added Files:
	.cvsignore 
Log Message:
ignore auto-generated files

--- NEW FILE .cvsignore ---
*.o.flags
.depend


From tharbaugh at lnxi.com  Wed Apr 16 12:09:28 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd/chips .cvsignore,NONE,1.1
Message-ID: <E195pTU-00077w-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv27376/chips

Added Files:
	.cvsignore 
Log Message:
ignore auto-generated files

--- NEW FILE .cvsignore ---
*.o.flags
.depend


From tharbaugh at lnxi.com  Wed Apr 16 12:09:29 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd/maps .cvsignore,NONE,1.1
Message-ID: <E195pTV-000783-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv27376/maps

Added Files:
	.cvsignore 
Log Message:
ignore auto-generated files

--- NEW FILE .cvsignore ---
*.o.flags
.depend


From tharbaugh at lnxi.com  Wed Apr 16 12:09:27 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd .cvsignore,NONE,1.1
Message-ID: <E195pTT-00077s-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv27376

Added Files:
	.cvsignore 
Log Message:
ignore auto-generated files

--- NEW FILE .cvsignore ---
*.o.flags
.depend


From tharbaugh at lnxi.com  Wed Apr 16 12:09:29 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd/nand .cvsignore,NONE,1.1
Message-ID: <E195pTV-000784-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv27376/nand

Added Files:
	.cvsignore 
Log Message:
ignore auto-generated files

--- NEW FILE .cvsignore ---
*.o.flags
.depend


From tharbaugh at lnxi.com  Fri Apr 18 12:01:00 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:07 2006
Subject: mtd/drivers/mtd/chips jedec_probe.c,1.24,1.25
Message-ID: <E196YIO-0000l1-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv2902

Modified Files:
	jedec_probe.c 
Log Message:
Fix various typos, code tidy

Index: jedec_probe.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/jedec_probe.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- jedec_probe.c	11 Apr 2003 15:08:26 -0000	1.24
+++ jedec_probe.c	18 Apr 2003 16:00:57 -0000	1.25
@@ -170,7 +170,7 @@
  * MTD_UADDR_NOT_SUPPORTED must be 0 and the first entry here
  * must go unused.
  */
-static struct unlock_addr  unlock_addrs[] = {
+static const struct unlock_addr  unlock_addrs[] = {
 	[MTD_UADDR_NOT_SUPPORTED] = {
 		.addr1 = 0xffff,
 		.addr2 = 0xffff
@@ -230,7 +230,7 @@
 /*
  * Please keep this list ordered by manufacturer!
  * Fortunately, the list isn't searched often and so a
- * sloppy, linear search isn't so bad.
+ * slow, linear search isn't so bad.
  */
 static const struct amd_flash_info jedec_table[] = {
 	{
@@ -922,7 +922,7 @@
 	}, {
 		mfr_id:          MANUFACTURER_PMC,
 		dev_id:          PM49FL002,
-		name:            "PMC_Pm49FL002",
+		name:            "PMC Pm49FL002",
  		uaddr:           {[0] = MTD_UADDR_0x5555_0x2AAA}, /* x8 */
 		DevSize:         SIZE_256KiB,
 		CmdSet:          P_ID_AMD_STD,
@@ -933,7 +933,7 @@
 	}, {
 		mfr_id:          MANUFACTURER_PMC,
 		dev_id:          PM49FL004,
-		name:            "PMC_Pm49FL004",
+		name:            "PMC Pm49FL004",
  		uaddr:           {[0] = MTD_UADDR_0x5555_0x2AAA}, /* x8 */
 		DevSize:         SIZE_512KiB,
 		CmdSet:          P_ID_AMD_STD,
@@ -944,7 +944,7 @@
 	}, {
 		mfr_id:          MANUFACTURER_PMC,
 		dev_id:          PM49FL008,
-		name:            "PMC_Pm49FL008",
+		name:            "PMC Pm49FL008",
  		uaddr:           {[0] = MTD_UADDR_0x5555_0x2AAA}, /* x8 */
 		DevSize:         SIZE_1MiB,
 		CmdSet:          P_ID_AMD_STD,
@@ -1452,8 +1452,7 @@
 			if ( jedec_match( base, map, cfi, &jedec_table[i] ) ) {
 				DEBUG( MTD_DEBUG_LEVEL3,
 				       "MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n",
-				       __func__,
-				       cfi->mfr, cfi->id,
+				       __func__, cfi->mfr, cfi->id,
 				       cfi->addr_unlock1, cfi->addr_unlock2 );
 				if (!cfi_jedec_setup(cfi, i))
 					return 0;


From gleixner at infradead.org  Sun Apr 20 03:24:43 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:07 2006
Subject: 
 mtd/drivers/mtd/nand autcpu12.c,1.9,1.10 edb7312.c,1.4,1.5 spia.c,1.18,1.19
Message-ID: <E1979Br-0001cJ-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv6206

Modified Files:
	autcpu12.c edb7312.c spia.c 
Log Message:
removed obsolete cache stuff

Index: autcpu12.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/autcpu12.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- autcpu12.c	20 Feb 2003 13:39:38 -0000	1.9
+++ autcpu12.c	20 Apr 2003 07:24:40 -0000	1.10
@@ -197,15 +197,6 @@
 		goto out_ior;
 	}
 
-	/* Allocate memory for internal data buffer */
-	this->data_cache = kmalloc (sizeof(u_char) * (autcpu12_mtd->oobblock + autcpu12_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_cache) {
-		printk ("Unable to allocate NAND data cache for AUTCPU12.\n");
-		err = -ENOMEM;
-		goto out_buf;
-	}
-	this->cache_page = -1;
-
 	/* Register the partitions */
 	switch(autcpu12_mtd->size){
 		case SZ_16M: add_mtd_partitions(autcpu12_mtd, partition_info16k, NUM_PARTITIONS16K); break;
@@ -215,13 +206,11 @@
 		default: {
 			printk ("Unsupported SmartMedia device\n"); 
 			err = -ENXIO;
-			goto out_cac;
+			goto out_buf;
 		}
 	}
 	goto out;
 
-out_cac:
-	kfree (this->data_cache);    
 out_buf:
 	kfree (this->data_buf);    
 out_ior:
@@ -250,7 +239,6 @@
 
 	/* Free internal data buffers */
 	kfree (this->data_buf);
-	kfree (this->data_cache);
 
 	/* unmap physical adress */
 	iounmap((void *)autcpu12_fio_base);

Index: edb7312.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/edb7312.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- edb7312.c	17 Feb 2003 21:49:10 -0000	1.4
+++ edb7312.c	20 Apr 2003 07:24:40 -0000	1.5
@@ -186,17 +186,6 @@
 		return -ENOMEM;
 	}
 	
-	/* Allocate memory for internal data buffer */
-	this->data_cache = kmalloc (sizeof(u_char) * (ep7312_mtd->oobblock + ep7312_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_cache) {
-		printk("Unable to allocate NAND data cache for EDB7312.\n");
-		kfree (this->data_buf);
-		iounmap((void *)ep7312_fio_base);
-		kfree (ep7312_mtd);
-		return -ENOMEM;
-	}
-	this->cache_page = -1;
-	
 #ifdef CONFIG_MTD_CMDLINE_PARTS
 	mtd_parts_nb = parse_cmdline_partitions(ep7312_mtd, &mtd_parts, 
 						"edb7312-nand");
@@ -233,7 +222,6 @@
 	
 	/* Free internal data buffer */
 	kfree (this->data_buf);
-	kfree (this->data_cache);
 	
 	/* Free the MTD device structure */
 	kfree (ep7312_mtd);

Index: spia.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/spia.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- spia.c	2 Mar 2003 18:50:37 -0000	1.18
+++ spia.c	20 Apr 2003 07:24:40 -0000	1.19
@@ -156,16 +156,6 @@
 		return -ENOMEM;
 	}
 
-	/* Allocate memory for internal data buffer */
-	this->data_cache = kmalloc (sizeof(u_char) * (spia_mtd->oobblock + spia_mtd->oobsize), GFP_KERNEL);
-	if (!this->data_cache) {
-		printk ("Unable to allocate NAND data cache for SPIA.\n");
-		kfree (this->data_buf);
-		kfree (spia_mtd);
-		return = -ENOMEM;
-	}
-	this->cache_page = -1;
-
 	/* Register the partitions */
 	add_mtd_partitions(spia_mtd, partition_info, NUM_PARTITIONS);
 
@@ -187,7 +177,6 @@
 
 	/* Free internal data buffer */
 	kfree (this->data_buf);
-	kfree (this->page_cache);
 
 	/* Free the MTD device structure */
 	kfree (spia_mtd);


From gleixner at infradead.org  Sun Apr 20 03:25:21 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:07 2006
Subject: mtd/include/linux/mtd nand.h,1.22,1.23
Message-ID: <E1979CT-0001cg-00@phoenix.infradead.org>

Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv6229

Modified Files:
	nand.h 
Log Message:
removed obsolete cache stuff

Index: nand.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/nand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- nand.h	20 Feb 2003 13:39:38 -0000	1.22
+++ nand.h	20 Apr 2003 07:25:18 -0000	1.23
@@ -173,10 +173,8 @@
 	wait_queue_head_t wq;
 	nand_state_t 	state;
 	int 		page_shift;
-	u_char 		*data_buf;
-	u_char		*data_poi;
-	u_char 		*data_cache;
-	int		cache_page;
+	volatile u_char *data_buf;
+	volatile u_char	*data_poi;
 };
 
 /*


From gleixner at infradead.org  Sun Apr 20 03:28:51 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:07 2006
Subject: mtd/include/linux/mtd nand.h,1.23,1.24
Message-ID: <E1979Fr-0001cz-00@phoenix.infradead.org>

Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv6248

Modified Files:
	nand.h 
Log Message:
removed nonsense volatile

Index: nand.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/nand.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- nand.h	20 Apr 2003 07:25:18 -0000	1.23
+++ nand.h	20 Apr 2003 07:28:48 -0000	1.24
@@ -173,8 +173,8 @@
 	wait_queue_head_t wq;
 	nand_state_t 	state;
 	int 		page_shift;
-	volatile u_char *data_buf;
-	volatile u_char	*data_poi;
+	u_char 		*data_buf;
+	u_char		*data_poi;
 };
 
 /*


From gleixner at infradead.org  Sun Apr 20 04:38:04 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:08 2006
Subject: mtd/drivers/mtd/maps h720x-flash.c,NONE,1.1 Config.in,1.46,1.47
 Kconfig,1.5,1.6 Makefile,1.39,1.40
Message-ID: <E197AKq-0001vR-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv7392

Modified Files:
	Config.in Kconfig Makefile 
Added Files:
	h720x-flash.c 
Log Message:
add support for hynix evaluation boards

--- NEW FILE h720x-flash.c ---
/*
 * Flash memory access on Hynix GMS30C7201/HMS30C7202 based 
 * evaluation boards
 * 
 * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com>
 *     2003 Thomas Gleixner <tglx@linutronix.de>	
*/

#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>

#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>

#include <asm/hardware.h>
#include <asm/io.h>

static struct mtd_info *mymtd;

static __u8 h720x_read8(struct map_info *map, unsigned long ofs)
{
	return readb(map->map_priv_1 + ofs);
}

static __u16 h720x_read16(struct map_info *map, unsigned long ofs)
{
	return readw(map->map_priv_1 + ofs);
}

static __u32 h720x_read32(struct map_info *map, unsigned long ofs)
{
	return readl(map->map_priv_1 + ofs);
}

static void h720x_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
	memcpy_fromio(to, map->map_priv_1 + from, len);
}

static void h720x_write8(struct map_info *map, __u8 d, unsigned long adr)
{
	writeb(d, map->map_priv_1 + adr);
}

static void h720x_write16(struct map_info *map, __u16 d, unsigned long adr)
{
	writew(d, map->map_priv_1 + adr);
}

static void h720x_write32(struct map_info *map, __u32 d, unsigned long adr)
{
	writel(d, map->map_priv_1 + adr);
}

static void h720x_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
	memcpy_toio(map->map_priv_1 + to, from, len);
}

static struct map_info h720x_map = {
	name:		"H720X",
	read8:		h720x_read8,
	read16:		h720x_read16,
	read32:		h720x_read32,
	copy_from:	h720x_copy_from,
	write8:		h720x_write8,
	write16:	h720x_write16,
	write32:	h720x_write32,
	copy_to:	h720x_copy_to,
	buswidth:	4,
	size:		FLASH_SIZE
};

static struct mtd_partition h720x_partitions[] = {
        {
                name: "ArMon",
                size: 0x00080000,
                offset: 0,
                mask_flags: MTD_WRITEABLE
        },{
                name: "Env",
                size: 0x00040000,
                offset: 0x00080000,
                mask_flags: MTD_WRITEABLE
        },{
                name: "Kernel",
                size: 0x00180000,
                offset: 0x000c0000,
                mask_flags: MTD_WRITEABLE
        },{
                name: "Ramdisk",
                size: 0x00400000,
                offset: 0x00240000,
                mask_flags: MTD_WRITEABLE
        },{
                name: "jffs2",
                size: MTDPART_SIZ_FULL,
                offset: MTDPART_OFS_APPEND
        }
};

#define NUM_PARTITIONS  (sizeof(h720x_partitions)/sizeof(h720x_partitions[0]))

static int                   nr_mtd_parts;
static struct mtd_partition *mtd_parts;

/*
 * Initialize FLASH support
 */
int __init h720x_mtd_init(void)
{

	char	*part_type = NULL;
	
	h720x_map.map_priv_1 = (unsigned long)ioremap(FLASH_PHYS, FLASH_SIZE);

	if (!h720x_map.map_priv_1) {
		printk(KERN_ERR "H720x-MTD: ioremap failed\n");
		return -EIO;
	}

	// Probe for flash buswidth 4
	printk (KERN_INFO "H720x-MTD probing 32bit FLASH\n");
	mymtd = do_map_probe("cfi_probe", &h720x_map);
	if (!mymtd) {
		printk (KERN_INFO "H720x-MTD probing 16bit FLASH\n");
	    // Probe for buswidth 2
	    h720x_map.buswidth = 2;
	    mymtd = do_map_probe("cfi_probe", &h720x_map);
	}
	    
	if (mymtd) {
		mymtd->module = THIS_MODULE;

#ifdef CONFIG_MTD_CMDLINE_PARTS
		nr_mtd_parts = parse_cmdline_partitions(mymtd, &mtd_parts, h720x_map.name);
		if (nr_mtd_parts > 0)
			part_type = "command line";
#endif
		if (nr_mtd_parts <= 0) {
			mtd_parts = h720x_partitions;
			nr_mtd_parts = NUM_PARTITIONS;
			part_type = "builtin";
		}
		printk(KERN_INFO "Using %s partition table\n", part_type);
		add_mtd_partitions(mymtd, mtd_parts, nr_mtd_parts);
		return 0;
	}

	iounmap((void *)h720x_map.map_priv_1);
	return -ENXIO;
}

/*
 * Cleanup
 */
static void __exit h720x_mtd_cleanup(void)
{

	if (mymtd) {
		del_mtd_partitions(mymtd);
		map_destroy(mymtd);
	}
	
	/* Free partition info, if commandline partition was used */
	if (mtd_parts && (mtd_parts != h720x_partitions))
		kfree (mtd_parts);
	
	if (h720x_map.map_priv_1) {
		iounmap((void *)h720x_map.map_priv_1);
		h720x_map.map_priv_1 = 0;
	}
}


module_init(h720x_mtd_init);
module_exit(h720x_mtd_cleanup);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>");
MODULE_DESCRIPTION("MTD map driver for Hynix evaluation boards");

Index: Config.in
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/Config.in,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- Config.in	10 Apr 2003 12:20:18 -0000	1.46
+++ Config.in	20 Apr 2003 08:38:01 -0000	1.47
@@ -105,6 +105,7 @@
    dep_tristate '  CFI Flash device mapped on the FortuNet board' CONFIG_MTD_FORTUNET $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_SA1100_FORTUNET
    dep_tristate '  NV-RAM mapping AUTCPU12 board' CONFIG_MTD_AUTCPU12 $CONFIG_ARCH_AUTCPU12
    dep_tristate '  CFI Flash device mapped on EDB7312' CONFIG_MTD_EDB7312 $CONFIG_MTD_CFI
+   dep_tristate '  CFI Flash device mapped on Hynix evaluation boards' CONFIG_MTD_H720X $CONFIG_MTD_CFI
    dep_tristate '  JEDEC Flash device mapped on impA7' CONFIG_MTD_IMPA7 $CONFIG_MTD_JEDECPROBE
    dep_tristate '  JEDEC Flash device mapped on Ceiva/Polaroid PhotoMax Digital Picture Frame' CONFIG_MTD_CEIVA $CONFIG_MTD_JEDECPROBE  $CONFIG_ARCH_CEIVA
 fi

Index: Kconfig
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/Kconfig,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Kconfig	10 Apr 2003 12:20:19 -0000	1.5
+++ Kconfig	20 Apr 2003 08:38:01 -0000	1.6
@@ -366,6 +366,13 @@
 	  PhotoMax Digital Picture Frame.
 	  If you have such a device, say 'Y'.
 
+config MTD_H720X
+	tristate "Hynix evaluation board mappings"
+	depends on ARM && MTD_CFI && ( ARCH_H7201 || ARCH_H7202 )
+	help
+	  This enables access to the flash chips on the Hynix evaluation boards.
+	  If you have such a board, say 'Y'.
+
 # This needs CFI or JEDEC, depending on the cards found.
 config MTD_PCI
 	tristate "PCI MTD driver"

Index: Makefile
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/Makefile,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- Makefile	10 Apr 2003 12:20:18 -0000	1.39
+++ Makefile	20 Apr 2003 08:38:01 -0000	1.40
@@ -65,5 +65,6 @@
 obj-$(CONFIG_MTD_EBONY)		+= ebony.o
 obj-$(CONFIG_MTD_BEECH)		+= beech-mtd.o
 obj-$(CONFIG_MTD_ARCTIC)	+= arctic-mtd.o
+obj-$(CONFIG_MTD_H720X)		+= h720x-flash.o
 
 include $(TOPDIR)/Rules.make


From tharbaugh at lnxi.com  Mon Apr 21 19:26:28 2003
From: tharbaugh at lnxi.com (Thayne Harbaugh)
Date: Mon May 15 21:48:08 2006
Subject: mtd/drivers/mtd/chips cfi_cmdset_0002.c,1.67,1.68
Message-ID: <E197kg8-0004aL-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv17616

Modified Files:
	cfi_cmdset_0002.c 
Log Message:
Remove dq5 check from erase/write status polling.
dq5 is now only used to decode failures - using dq5 to
check status _greatly_ complicates the logic and only
optimizes the error case (which should be infrequent at
best).
Added benefit - chips that do not use dq5 now work - they
might have strange error reports when they timeout.
Future fixes should select cmdset_0002 capabilities for
chips that support dq7, dq6, dq5, dq2, erase suspend/resume,
etc.

Index: cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- cfi_cmdset_0002.c	15 Apr 2003 22:32:13 -0000	1.67
+++ cfi_cmdset_0002.c	21 Apr 2003 23:26:25 -0000	1.68
@@ -472,6 +472,7 @@
     static unsigned long uWriteTimeout = ( HZ / 1000 ) + 1;
 	DECLARE_WAITQUEUE(wait, current);
 	int ret = 0;
+	int ta = 0;
 
  retry:
 	cfi_spin_lock(chip->mutex);
@@ -554,30 +555,23 @@
 	       __func__, oldstatus, status );
 
 	/*
-	 * This assumes that dq5 == dq6 >> 1
-	 * It's done this way so that we only look for asserted dq5
-	 * on interleaved chips that are still toggling - we can
-	 * ignore chips that have already completed and might have
-	 * dq5 asserted.  It is important to use oldstatus because
-	 * a completed state might look like it has toggled from
-	 * the previous read of status bits and it might trigger
-	 * an erroneous error.
+	 * This only checks if dq6 is still toggling and that our
+	 * timer hasn't expired.  We purposefully ignore the chips
+	 * internal timer that will assert dq5 and leave dq6 toggling.
+	 * This is done for a variety of reasons:
+	 * 1) Not all chips support dq5.
+	 * 2) Dealing with asynchronous status bit and data updates
+	 *    and reading a device two more times creates _messy_
+	 *    logic when trying to deal with interleaved devices -
+	 *    some may be changing while others are still busy.
+	 * 3) Checking dq5 only helps to optimize an error case that
+	 *    should at worst be infrequent and at best non-existent.
 	 *
-	 * FIXME - this is rather complicated - trying to deal with
-	 * asynchronous transitions and cases where the toggle bit
-	 * appears to toggle when it has really just settled to true
-	 * data and having to read the locations an additional two
-	 * times to verify bits.  It might be that we just need
-	 * to watch dq6 and our timeout and ignore dq5.  If the
-	 * timeout is exceeded and we still have dq6 toggling we then
-	 * look for asserted dq5 for each toggling dq6.  That would
-	 * be safer, easier to code and get correct, and marginally
-	 * less efficient.  Who cares if the error case, which should
-	 * be very infrequent, is optimized.
+	 * If our timeout occurs _then_ we will check dq5 to see
+	 * if the device also had an internal timeout.
 	 */
 	while( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 ) >> 1 )
-	       && ! time_after(jiffies, timeo) ) {
+	       && ! ( ta = time_after(jiffies, timeo) ) ) {
 
 		if (need_resched()) {
 			cfi_spin_unlock(chip->mutex);
@@ -592,35 +586,19 @@
 		       __func__, oldstatus, status );
 	}
 
-	if ( ( ( status ^ oldstatus ) & dq6 )
-	     && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 ) >> 1 ) ) {
-		/* dq6 still toggling and dq5 still low - must be timeout */
-		printk( KERN_WARNING
-			"MTD %s(): Timed out while waiting for write to complete.\n",
-			__func__ );
-		goto write_failed;
-	}
-
 	/*
-	 * Either dq5 went high or dq6 finish toggling.  For
-	 * the correct completion of certain types of writes
-	 * dq5 might _appear_ to go high while dq6 might
-	 * _appear_ to still be toggling - it depends on the
-	 * last toggle-state dq6 was in and what the final
-	 * state will be with true data.  We alread know that
-	 * something changed state with the last set of reads.
+	 * Something kicked us out of the read-back loop.  We'll
+	 * check success befor checking failure.
+	 * Even though dq6 might be true data, it is unkown if
+	 * all of the other bits have changed to true data due to
+	 * the asynchronous nature of the internal state machine.
 	 * We will read two more times and use this to either
 	 * verify that the write completed successfully or
 	 * that something really went wrong.  BOTH reads
 	 * must match what was written - this certifies that
-	 * dq6 is not still toggling  and that the status
+	 * bits aren't still changing  and that the status
 	 * bits erroneously match the datum that was written.
 	 */
-
-	/*
-	 * Be optimistic and check success first - then decode any
-	 * failures.
-	 */
 	prev_oldstatus = oldstatus;
 	prev_status = status;
 	oldstatus = cfi_read(map, adr);
@@ -633,24 +611,31 @@
 		goto write_done;
 	}
 
-	/* something has failed */
-	if ( ( ( status ^ oldstatus ) & dq6 )
-	     && ( status & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
-		printk(KERN_WARNING
-		       "MTD %s(): Internal flash device timeout occured.\n",
-		       __func__ );
-	} else {
-		/*
-		 * If we get to here then it means that something failed
-		 * and that the usual error state of toggling dq6
-		 * while dq5 goes high did not happen.  Something
-		 * is seriously wacky!  Dump some debug info.
-		 */
-		printk(KERN_WARNING
-		       "MTD %s(): Wacky!  Unable to decode failure status\n",
-		       __func__ );
+	if ( ta ) {
+		int dq5mask = ( ( status ^ oldstatus ) & dq6 ) >> 1;
+		if ( status & dq5mask ) {
+			/* dq5 asserted - decode interleave chips */
+			printk( KERN_WARNING
+				"MTD %s(): FLASH internal timeout: 0x%.8x\n",
+				__func__,
+				status & dq5mask );
+		} else {
+			printk( KERN_WARNING
+				"MTD %s(): Software timed out during write.\n",
+				__func__ );
+		}
+		goto write_failed;
 	}
 
+	/*
+	 * If we get to here then it means that something
+	 * is wrong and it's not a timeout.  Something
+	 * is seriously wacky!  Dump some debug info.
+	 */
+	printk(KERN_WARNING
+	       "MTD %s(): Wacky!  Unable to decode failure status\n",
+	       __func__ );
+
 	printk(KERN_WARNING
 	       "MTD %s(): 0x%.8lx(0x%.8x): 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",
 	       __func__, adr, datum,
@@ -825,6 +810,7 @@
 	struct cfi_private *cfi = map->fldrv_priv;
 	DECLARE_WAITQUEUE(wait, current);
 	int ret = 0;
+	int ta = 0;
 	__u32 ones = 0;
 
  retry:
@@ -882,8 +868,7 @@
 	       __func__, oldstatus, status );
 
 	while( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) )
-	       && ! time_after(jiffies, timeo) ) {
+	       && ! ( ta = time_after(jiffies, timeo) ) ) {
 		int wait_reps;
 
 		/* an initial short sleep */
@@ -913,8 +898,7 @@
 		/* Busy wait for 1/10 of a milisecond */
 		for(wait_reps = 0;
 		    (wait_reps < 100)
-			    && ( ( status ^ oldstatus ) & dq6 )
-			    && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) );
+			    && ( ( status ^ oldstatus ) & dq6 );
 		    wait_reps++) {
 			
 			/* Latency issues. Drop the lock, wait a while and retry */
@@ -934,62 +918,41 @@
 		       __func__, oldstatus, status );
 	}
 
-	if ( ( ( status ^ oldstatus ) & dq6 )
-	     && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
-		/* dq6 still toggling and dq5 still low - must be timeout */
-		printk( KERN_WARNING
-			"MTD %s(): Timed out while waiting for erase to complete.\n",
-			__func__ );
-		goto erase_failed;
-	}
-
-	/*
-	 * Be optimistic and check success first - then decode any
-	 * failures.
-	 */
 	prev_oldstatus = oldstatus;
 	prev_status = status;
 	oldstatus = cfi_read(map, adr);
 	status = cfi_read(map, adr);
 	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
 	       __func__, oldstatus, status );
-		
-	switch( CFIDEV_BUSWIDTH ) {
-	case 1:
-		ones = (__u8)~0;
-		break;
-	case 2:
-		ones = (__u16)~0;
-		break;
-	case 4:
-		ones = (__u32)~0;
-		break;
-	}
+
+	ones = CMD( (__u8)~0 );
 	
 	if ( oldstatus == ones && status == ones ) {
 		/* success - do nothing */
 		goto erase_done;
 	}
 
-	/* something has failed */
-	if ( ( ( status ^ oldstatus ) & dq6 )
-	     && ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
-		printk(KERN_WARNING
-		       "MTD %s(): Internal flash device timeout occured.\n",
-		       __func__ );
-	} else {
-		/*
-		 * This state means that the erase did not succeed
-		 * and that the usual error state of toggling dq6
-		 * while dq5 goes high did not happen.  Something
-		 * is seriously wacky!
-		 */
-		printk(KERN_WARNING
-		       "MTD %s(): Wacky!  Unable to decode failure status\n",
-		       __func__ );
+	if ( ta ) {
+		int dq5mask = ( ( status ^ oldstatus ) & dq6 ) >> 1;
+		if ( status & dq5mask ) {
+			/* dq5 asserted - decode interleave chips */
+			printk( KERN_WARNING
+				"MTD %s(): FLASH internal timeout: 0x%.8x\n",
+				__func__,
+				status & dq5mask );
+		} else {
+			printk( KERN_WARNING
+				"MTD %s(): Software timed out during write.\n",
+				__func__ );
+		}
+		goto erase_failed;
 	}
 
 	printk(KERN_WARNING
+	       "MTD %s(): Wacky!  Unable to decode failure status\n",
+	       __func__ );
+
+	printk(KERN_WARNING
 	       "MTD %s(): 0x%.8lx(0x%.8x): 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",
 	       __func__, adr, ones,
 	       prev_oldstatus, prev_status,
@@ -1017,6 +980,7 @@
 	struct cfi_private *cfi = map->fldrv_priv;
 	DECLARE_WAITQUEUE(wait, current);
 	int ret = 0;
+	int ta = 0;
 	__u32 ones = 0;
 
  retry:
@@ -1074,8 +1038,7 @@
 	       __func__, oldstatus, status );
 
 	while( ( ( status ^ oldstatus ) & dq6 )
-	       && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) )
-	       && ! time_after(jiffies, timeo) ) {
+	       && ! ( ta = time_after(jiffies, timeo) ) ) {
 		int wait_reps;
 
 		/* an initial short sleep */
@@ -1105,8 +1068,7 @@
 		/* Busy wait for 1/10 of a milisecond */
 		for(wait_reps = 0;
 		    (wait_reps < 100)
-			    && ( ( status ^ oldstatus ) & dq6 )
-			    && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) );
+			    && ( ( status ^ oldstatus ) & dq6 );
 		    wait_reps++) {
 			
 			/* Latency issues. Drop the lock, wait a while and retry */
@@ -1126,19 +1088,6 @@
 		       __func__, oldstatus, status );
 	}
 
-	if ( ( ( status ^ oldstatus ) & dq6 )
-	     && ! ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
-		/* dq6 still toggling and dq5 still low - must be timeout */
-		printk( KERN_WARNING
-			"MTD %s(): Timed out while waiting for erase to complete.\n",
-			__func__ );
-		goto erase_failed;
-	}
-
-	/*
-	 * Be optimistic and check success first - then decode any
-	 * failures.
-	 */
 	prev_oldstatus = oldstatus;
 	prev_status = status;
 	oldstatus = cfi_read(map, adr);
@@ -1146,40 +1095,32 @@
 	DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): Check 0x%.8x 0x%.8x\n",
 	       __func__, oldstatus, status );
 
-	switch( CFIDEV_BUSWIDTH ) {
-	case 1:
-		ones = (__u8)~0;
-		break;
-	case 2:
-		ones = (__u16)~0;
-		break;
-	case 4:
-		ones = (__u32)~0;
-		break;
-	}
-	
+	ones = CMD( (__u8)~0 );
+
 	if ( oldstatus == ones && status == ones ) {
 		/* success - do nothing */
 		goto erase_done;
 	}
 
-	/* something has failed */
-	if ( ( ( status ^ oldstatus ) & dq6 )
-	     && ( oldstatus & ( ( status ^ oldstatus ) & dq6 >> 1 ) ) ) {
-		printk(KERN_WARNING
-		       "MTD %s(): Internal flash device timeout occured.\n",
-		       __func__ );
-	} else {
-		/*
-		 * This state means that the erase did not succeed
-		 * and that the usual error state of toggling dq6
-		 * while dq5 goes high did not happen.  Something
-		 * is seriously wacky!
-		 */
-		printk(KERN_WARNING
-		       "MTD %s(): Wacky!  Unable to decode failure status\n",
-		       __func__ );
+	if ( ta ) {
+		int dq5mask = ( ( status ^ oldstatus ) & dq6 ) >> 1;
+		if ( status & dq5mask ) {
+			/* dq5 asserted - decode interleave chips */
+			printk( KERN_WARNING
+				"MTD %s(): FLASH internal timeout: 0x%.8x\n",
+				__func__,
+				status & dq5mask );
+		} else {
+			printk( KERN_WARNING
+				"MTD %s(): Software timed out during write.\n",
+				__func__ );
+		}
+		goto erase_failed;
 	}
+
+	printk(KERN_WARNING
+	       "MTD %s(): Wacky!  Unable to decode failure status\n",
+	       __func__ );
 
 	printk(KERN_WARNING
 	       "MTD %s(): 0x%.8lx(0x%.8x): 0x%.8x 0x%.8x 0x%.8x 0x%.8x\n",


From joern at infradead.org  Tue Apr 22 16:12:50 2003
From: joern at infradead.org (joern@infradead.org)
Date: Mon May 15 21:48:08 2006
Subject: mtd/drivers/mtd/devices lart.c,1.2,1.3
Message-ID: <E19848I-0002q3-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/devices
In directory phoenix.infradead.org:/tmp/cvs-serv10898

Modified Files:
	lart.c 
Log Message:
Committed Art Haas' c99 conversion.



Index: lart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/lart.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- lart.c	2 Oct 2001 15:05:13 -0000	1.2
+++ lart.c	22 Apr 2003 20:12:47 -0000	1.3
@@ -584,46 +584,41 @@
 
 static struct mtd_info mtd;
 
-static struct mtd_erase_region_info erase_regions[] =
-{
-   /* parameter blocks */
-   {
-	     offset: 0x00000000,
-	  erasesize: FLASH_BLOCKSIZE_PARAM,
-	  numblocks: FLASH_NUMBLOCKS_16m_PARAM
-   },
-   /* main blocks */
-   {
-	     offset: FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM,
-	  erasesize: FLASH_BLOCKSIZE_MAIN,
-	  numblocks: FLASH_NUMBLOCKS_16m_MAIN
-   }
+static struct mtd_erase_region_info erase_regions[] = {
+	/* parameter blocks */
+	{
+		.offset		= 0x00000000,
+		.erasesize	= FLASH_BLOCKSIZE_PARAM,
+		.numblocks	= FLASH_NUMBLOCKS_16m_PARAM,
+	},
+	/* main blocks */
+	{
+		.offset	 = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM,
+		.erasesize	= FLASH_BLOCKSIZE_MAIN,
+		.numblocks	= FLASH_NUMBLOCKS_16m_MAIN,
+	}
 };
 
 #ifdef HAVE_PARTITIONS
-static struct mtd_partition lart_partitions[] =
-{
-   /* blob */
-   {
-	       name: "blob",
-	     offset: BLOB_START,
-	       size: BLOB_LEN,
-	 mask_flags: 0
-   },
-   /* kernel */
-   {
-	       name: "kernel",
-	     offset: KERNEL_START,			/* MTDPART_OFS_APPEND */
-	       size: KERNEL_LEN,
-	 mask_flags: 0
-   },
-   /* initial ramdisk / file system */
-   {
-	       name: "file system",
-	     offset: INITRD_START,			/* MTDPART_OFS_APPEND */
-	       size: INITRD_LEN,			/* MTDPART_SIZ_FULL */
-	 mask_flags: 0
-   }
+static struct mtd_partition lart_partitions[] = {
+	/* blob */
+	{
+		.name	= "blob",
+		.offset	= BLOB_START,
+		.size	= BLOB_LEN,
+	},
+	/* kernel */
+	{
+		.name	= "kernel",
+		.offset	= KERNEL_START,		/* MTDPART_OFS_APPEND */
+		.size	= KERNEL_LEN,
+	},
+	/* initial ramdisk / file system */
+	{
+		.name	= "file system",
+		.offset	= INITRD_START,		/* MTDPART_OFS_APPEND */
+		.size	= INITRD_LEN,		/* MTDPART_SIZ_FULL */
+	}
 };
 #endif
 


From dwmw2 at infradead.org  Mon Apr 28 06:17:19 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:08 2006
Subject: mtd/fs/jffs2 scan.c,1.98,1.99
Message-ID: <E19A5hH-0006ho-00@phoenix.infradead.org>

Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv25756

Modified Files:
	scan.c 
Log Message:
Fix oops on NAND with wrong-endian fs


Index: scan.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/scan.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- scan.c	22 Jan 2003 16:33:39 -0000	1.98
+++ scan.c	28 Apr 2003 10:17:17 -0000	1.99
@@ -410,8 +410,8 @@
 			/* Ran off end. */
 			D1(printk(KERN_DEBUG "Empty flash ends normally at 0x%08x\n", ofs));
 
-			if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && 
-			    !jeb->first_node->next_in_ino && !jeb->dirty_size)
+			if (buf_ofs == jeb->offset &&  jeb->used_size == PAD(c->cleanmarker_size) && 
+			    c->cleanmarker_size && !jeb->first_node->next_in_ino && !jeb->dirty_size)
 				return BLK_STATE_CLEANMARKER;
 			wasempty = 1;
 			continue;
@@ -430,7 +430,7 @@
 			continue;
 		}
 		if (je16_to_cpu(node->magic) == JFFS2_DIRTY_BITMASK) {
-			D1(printk(KERN_DEBUG "Empty bitmask at 0x%08x\n", ofs));
+			D1(printk(KERN_DEBUG "Dirty bitmask at 0x%08x\n", ofs));
 			DIRTY_SPACE(4);
 			ofs += 4;
 			continue;


From dwmw2 at infradead.org  Mon Apr 28 06:55:15 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:08 2006
Subject: mtd/drivers/mtd/chips cfi_cmdset_0001.c,1.114,1.115
Message-ID: <E19A6Hz-000711-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv26948

Modified Files:
	cfi_cmdset_0001.c 
Log Message:
Read prot reg is JEDEC_QUERY state not CFI_QUERY

Index: cfi_cmdset_0001.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0001.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- cfi_cmdset_0001.c	18 Mar 2003 12:28:40 -0000	1.114
+++ cfi_cmdset_0001.c	28 Apr 2003 10:55:12 -0000	1.115
@@ -694,7 +694,7 @@
 			count--;
 		}
 	       
-		chip->state=FL_CFI_QUERY;
+		chip->state=FL_JEDEC_QUERY;
 		spin_unlock(chip->mutex);
 		/* Move on to the next chip */
 		chip_num++;


From dwmw2 at infradead.org  Mon Apr 28 11:16:24 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:08 2006
Subject: mtd/drivers/mtd/chips cfi_cmdset_0001.c,1.115,1.116
Message-ID: <E19AAMi-0008Tu-00@phoenix.infradead.org>

Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv32583

Modified Files:
	cfi_cmdset_0001.c 
Log Message:
Common get_chip() function.


Index: cfi_cmdset_0001.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0001.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- cfi_cmdset_0001.c	28 Apr 2003 10:55:12 -0000	1.115
+++ cfi_cmdset_0001.c	28 Apr 2003 15:16:21 -0000	1.116
@@ -32,7 +32,8 @@
 #include <linux/mtd/cfi.h>
 #include <linux/mtd/compatmac.h>
 
-// debugging, turns off buffer write mode #define FORCE_WORD_WRITE
+// debugging, turns off buffer write mode if set to 1
+#define FORCE_WORD_WRITE 0
 
 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
@@ -52,11 +53,16 @@
 
[...1070 lines suppressed...]
-			 * as the whole point is that nobody can do anything
-			 * with the chip now anyway.
-			 */
-		case FL_PM_SUSPENDED:
-			break;
-
+			if (chip->oldstate == FL_READY) {
+				chip->oldstate = chip->state;
+				chip->state = FL_PM_SUSPENDED;
+				/* No need to wake_up() on this state change - 
+				 * as the whole point is that nobody can do anything
+				 * with the chip now anyway.
+				 */
+			}
 		default:
 			ret = -EAGAIN;
+		case FL_PM_SUSPENDED:
 			break;
 		}
 		spin_unlock(chip->mutex);


From jocke at infradead.org  Mon Apr 28 12:44:26 2003
From: jocke at infradead.org (Joakim Tjernlund)
Date: Mon May 15 21:48:08 2006
Subject: mtd/include/linux/mtd compatmac.h,1.45,1.46
Message-ID: <E19ABju-0000jb-00@phoenix.infradead.org>

Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv2812

Modified Files:
	compatmac.h 
Log Message:
set_user_nice() is not in 2.4.21 either.

Index: compatmac.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/compatmac.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- compatmac.h	24 Jan 2003 15:50:57 -0000	1.45
+++ compatmac.h	28 Apr 2003 16:44:23 -0000	1.46
@@ -519,7 +519,7 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 	/* Is this right? */
 #define set_user_nice(tsk, n) do { (tsk)->priority = 20-(n); } while(0) 
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,4,21) && !defined(RED_HAT_LINUX_KERNEL)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 #define set_user_nice(tsk, n) do { (tsk)->nice = n; } while(0)
 #endif
 


From jocke at infradead.org  Mon Apr 28 12:53:48 2003
From: jocke at infradead.org (Joakim Tjernlund)
Date: Mon May 15 21:48:08 2006
Subject: mtd/include/linux/mtd compatmac.h,1.46,1.47
Message-ID: <E19ABsy-0000lV-00@phoenix.infradead.org>

Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv2932

Modified Files:
	compatmac.h 
Log Message:
Oops, removed the RED_HAT_LINUX_KERNEL stuff by mistake

Index: compatmac.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/compatmac.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- compatmac.h	28 Apr 2003 16:44:23 -0000	1.46
+++ compatmac.h	28 Apr 2003 16:53:45 -0000	1.47
@@ -519,7 +519,7 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
 	/* Is this right? */
 #define set_user_nice(tsk, n) do { (tsk)->priority = 20-(n); } while(0) 
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) && !defined(RED_HAT_LINUX_KERNEL)
 #define set_user_nice(tsk, n) do { (tsk)->nice = n; } while(0)
 #endif
 


From dwmw2 at infradead.org  Tue Apr 29 05:53:02 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:08 2006
Subject: mtd/fs/jffs2 dir.c,1.74,1.75 gc.c,1.101,1.102 fs.c,1.23,1.24
Message-ID: <E19ARnK-0006kN-00@phoenix.infradead.org>

Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv25916

Modified Files:
	dir.c gc.c fs.c 
Log Message:
Byteswap as appropriate for device node payload.


Index: dir.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/dir.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- dir.c	14 Jan 2003 14:06:22 -0000	1.74
+++ dir.c	29 Apr 2003 09:52:58 -0000	1.75
@@ -588,7 +588,7 @@
 	struct jffs2_full_dnode *fn;
 	struct jffs2_full_dirent *fd;
 	int namelen;
-	unsigned short dev;
+	jint16_t dev;
 	int devlen = 0;
 	uint32_t alloclen, phys_ofs;
 	uint32_t writtenlen;
@@ -601,7 +601,7 @@
 	c = JFFS2_SB_INFO(dir_i->i_sb);
 	
 	if (S_ISBLK(mode) || S_ISCHR(mode)) {
-		dev = (MAJOR(rdev) << 8) | MINOR(rdev);
+		dev = cpu_to_je16((MAJOR(rdev) << 8) | MINOR(rdev));
 		devlen = sizeof(dev);
 	}
 	

Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/gc.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- gc.c	11 Mar 2003 17:19:56 -0000	1.101
+++ gc.c	29 Apr 2003 09:52:58 -0000	1.102
@@ -626,7 +626,7 @@
 {
 	struct jffs2_full_dnode *new_fn;
 	struct jffs2_raw_inode ri;
-	unsigned short dev;
+	jint16_t dev;
 	char *mdata = NULL, mdatalen = 0;
 	uint32_t alloclen, phys_ofs;
 	int ret;
@@ -635,8 +635,8 @@
 	    S_ISCHR(JFFS2_F_I_MODE(f)) ) {
 		/* For these, we don't actually need to read the old node */
 		/* FIXME: for minor or major > 255. */
-		dev =  ((JFFS2_F_I_RDEV_MAJ(f) << 8) | 
-			JFFS2_F_I_RDEV_MIN(f));
+		dev = cpu_to_je16(((JFFS2_F_I_RDEV_MAJ(f) << 8) | 
+			JFFS2_F_I_RDEV_MIN(f)));
 		mdata = (char *)&dev;
 		mdatalen = sizeof(dev);
 		D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bytes of kdev_t\n", mdatalen));

Index: fs.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/fs.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- fs.c	21 Jan 2003 18:11:28 -0000	1.23
+++ fs.c	29 Apr 2003 09:52:58 -0000	1.24
@@ -100,7 +100,7 @@
 	inode->i_blocks = (inode->i_size + 511) >> 9;
 	
 	switch (inode->i_mode & S_IFMT) {
-		unsigned short rdev;
+		jint16_t rdev;
 
 	case S_IFLNK:
 		inode->i_op = &jffs2_symlink_inode_operations;
@@ -147,7 +147,7 @@
 	case S_IFSOCK:
 	case S_IFIFO:
 		inode->i_op = &jffs2_file_inode_operations;
-		init_special_inode(inode, inode->i_mode, kdev_t_to_nr(mk_kdev(rdev>>8, rdev&0xff)));
+		init_special_inode(inode, inode->i_mode, kdev_t_to_nr(mk_kdev(je16_to_cpu(rdev)>>8, je16_to_cpu(rdev)&0xff)));
 		break;
 
 	default:


From dwmw2 at infradead.org  Tue Apr 29 09:06:42 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:08 2006
Subject: mtd/fs/jffs2 build.c,1.44,1.45
Message-ID: <E19AUok-00081d-00@phoenix.infradead.org>

Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv30829

Modified Files:
	build.c 
Log Message:
Fix for_each_inode() to be safer w.r.t. 'break'...

Well, here's my completely untested patch...

Thanks!
Rusty.


Index: build.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/build.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- build.c	17 Jan 2003 16:04:16 -0000	1.44
+++ build.c	29 Apr 2003 13:06:39 -0000	1.45
@@ -19,8 +19,30 @@
 int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *);
 int jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *);
 
+static inline struct jffs2_inode_cache *
+first_inode_chain(int *i, struct jffs2_sb_info *c)
+{
+	for (; *i <= INOCACHE_HASHSIZE; (*i)++) {
+		if (c->inocache_list[*i])
+			return c->inocache_list[*i];
+	}
+	return NULL;
+}
 
-#define for_each_inode(i, c, ic) for (i=0; i<INOCACHE_HASHSIZE; i++) for (ic=c->inocache_list[i]; ic; ic=ic->next) 
+static inline struct jffs2_inode_cache *
+next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c)
+{
+	/* More in this chain? */
+	if (ic->next)
+		return ic->next;
+	(*i)++;
+	return first_inode_chain(i, c);
+}
+
+#define for_each_inode(i, c, ic)			\
+	for (i = 0, ic = first_inode_chain(&i, (c));	\
+	     ic;					\
+	     ic = next_inode(&i, ic, (c)))
 
 /* Scan plan:
  - Scan physical nodes. Build map of inodes/dirents. Allocate inocaches as we go


From gleixner at infradead.org  Tue Apr 29 13:12:28 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:09 2006
Subject: mtd/fs/jffs2 build.c,1.45,1.46
Message-ID: <E19AYea-0001PJ-00@phoenix.infradead.org>

Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv5400

Modified Files:
	build.c 
Log Message:
keep it inside inocache

Index: build.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/build.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- build.c	29 Apr 2003 13:06:39 -0000	1.45
+++ build.c	29 Apr 2003 17:12:26 -0000	1.46
@@ -22,7 +22,7 @@
 static inline struct jffs2_inode_cache *
 first_inode_chain(int *i, struct jffs2_sb_info *c)
 {
-	for (; *i <= INOCACHE_HASHSIZE; (*i)++) {
+	for (; *i < INOCACHE_HASHSIZE; (*i)++) {
 		if (c->inocache_list[*i])
 			return c->inocache_list[*i];
 	}


From dwmw2 at infradead.org  Wed Apr 30 05:43:35 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:09 2006
Subject: mtd/fs/jffs2 build.c,1.16.2.2,1.16.2.3
Message-ID: <E19Ao7j-0008Rj-00@phoenix.infradead.org>

Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv32448

Modified Files:
      Tag: jffs2-2_4-branch
	build.c 
Log Message:
Jörn and Rusty are right -- I suck and for_each_inode() was broken.


Index: build.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/build.c,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -r1.16.2.2 -r1.16.2.3
--- build.c	12 Mar 2002 15:36:43 -0000	1.16.2.2
+++ build.c	30 Apr 2003 09:43:32 -0000	1.16.2.3
@@ -43,8 +43,30 @@
 int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *);
 int jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *);
 
+static inline struct jffs2_inode_cache *
+first_inode_chain(int *i, struct jffs2_sb_info *c)
+{
+	for (; *i < INOCACHE_HASHSIZE; (*i)++) {
+		if (c->inocache_list[*i])
+			return c->inocache_list[*i];
+	}
+	return NULL;
+}
 
-#define for_each_inode(i, c, ic) for (i=0; i<INOCACHE_HASHSIZE; i++) for (ic=c->inocache_list[i]; ic; ic=ic->next) 
+static inline struct jffs2_inode_cache *
+next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c)
+{
+	/* More in this chain? */
+	if (ic->next)
+		return ic->next;
+	(*i)++;
+	return first_inode_chain(i, c);
+}
+
+#define for_each_inode(i, c, ic)			\
+	for (i = 0, ic = first_inode_chain(&i, (c));	\
+	     ic;					\
+	     ic = next_inode(&i, ic, (c)))
 
 /* Scan plan:
  - Scan physical nodes. Build map of inodes/dirents. Allocate inocaches as we go


From dwmw2 at infradead.org  Wed Apr 30 07:15:25 2003
From: dwmw2 at infradead.org (David Woodhouse)
Date: Mon May 15 21:48:09 2006
Subject: mtd/include/linux/mtd flashchip.h,1.8,1.9
Message-ID: <E19ApYb-0000a5-00@phoenix.infradead.org>

Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv2207

Modified Files:
	flashchip.h 
Log Message:
Add erase_suspended flag


Index: flashchip.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/flashchip.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- flashchip.h	21 Oct 2002 13:20:52 -0000	1.8
+++ flashchip.h	30 Apr 2003 11:15:22 -0000	1.9
@@ -58,6 +58,10 @@
 	int ref_point_counter;
 	flstate_t state;
 	flstate_t oldstate;
+
+	int write_suspended:1;
+	int erase_suspended:1;
+
 	spinlock_t *mutex;
 	spinlock_t _spinlock; /* We do it like this because sometimes they'll be shared. */
 	wait_queue_head_t wq; /* Wait on here when we're waiting for the chip


From gleixner at infradead.org  Wed Apr 30 09:55:43 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:09 2006
Subject: mtd/util nandwrite.c,1.7,1.8
Message-ID: <E19As3j-0001pD-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv7006

Modified Files:
	nandwrite.c 
Log Message:
fix short options

Index: nandwrite.c
===================================================================
RCS file: /home/cvs/mtd/util/nandwrite.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- nandwrite.c	6 Mar 2003 20:31:02 -0000	1.7
+++ nandwrite.c	30 Apr 2003 13:55:40 -0000	1.8
@@ -105,7 +105,7 @@
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "q";
+		static const char *short_options = "os:jynq";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},


From gleixner at infradead.org  Wed Apr 30 11:13:03 2003
From: gleixner at infradead.org (gleixner@infradead.org)
Date: Mon May 15 21:48:09 2006
Subject: mtd/util jffs2dump.c,1.1,1.2 Makefile,1.30,1.31
Message-ID: <E19AtGZ-0002ND-00@phoenix.infradead.org>

Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv9114

Modified Files:
	jffs2dump.c Makefile 
Log Message:
Add bigendian support, add endianess conversion for fs images

Index: jffs2dump.c
===================================================================
RCS file: /home/cvs/mtd/util/jffs2dump.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- jffs2dump.c	8 Mar 2003 21:12:57 -0000	1.1
+++ jffs2dump.c	30 Apr 2003 15:13:00 -0000	1.2
@@ -29,14 +29,22 @@
 #include <sys/param.h>
 #include <asm/types.h>
 #include <dirent.h>
-#include "linux/jffs2.h"
+#include <linux/jffs2.h>
+#include <asm/byteorder.h>
 #include <getopt.h>
+#include "crc32.h"
 
 #define PROGRAM "jffs2dump"
 #define VERSION "1.0"
 
 #define PAD(x) (((x)+3)&~3)
 
+#define de32_to_cpu(x) (bigendian ? __be32_to_cpu(x.v32) : __le32_to_cpu(x.v32))
+#define de16_to_cpu(x) (bigendian ? __be16_to_cpu(x.v16) : __le16_to_cpu(x.v16))
+#define cnv_e32(x) ((jint32_t){(bigendian ? __be32_to_cpu(x.v32) : __le32_to_cpu(x.v32))})
+#define cnv_e16(x) ((jint16_t){(bigendian ? __be16_to_cpu(x.v16) : __le16_to_cpu(x.v16))})
+#define cpu_to_e32(x) ((jint32_t){(bigendian ? __cpu_to_le32(x) : __cpu_to_be32(x))})
+
 // Global variables
 long	imglen;		// length of image
 char	*data;		// image data
@@ -46,9 +54,13 @@
 	printf("Usage: dumpjffs2 [OPTION] INPUTFILE\n"
 	       "Dumps the contents of a binary JFFS2 image.\n"
 	       "\n"
-	       "      --help     	display this help and exit\n"
-	       "      --version  	output version information and exit\n"
-	       "-c    --content  	dump image contents\n");
+	       "           --help     	              display this help and exit\n"
+	       "           --version  	              output version information and exit\n"
+	       "-b         --bigendian	              image is bigendian\n"
+	       "-c         --content  	              dump image contents\n"
+	       "-e fname   --endianconvert=fname      convert image endianness, output to file fname\n"
+	       "-r         --recalccrc                recalc name and data crc on endian conversion\n" 	
+	       "-v         --verbose		      verbose output\n");
 	exit(0);
 }
 
@@ -69,9 +81,13 @@
 
 // Option variables
 
-int 	verbose;	// verbose output
-char 	*img;		// filename of image
-int	dumpcontent;	// dump image content
+int 	verbose;		// verbose output
+char 	*img;			// filename of image
+int	dumpcontent;		// dump image content
+int	bigendian;		// image is big endian
+int	convertendian;		// convert endianness
+int	recalccrc;		// recalc name and data crc's on endian conversion
+char	cnvfile[256];		// filename for conversion output
 
 void process_options (int argc, char *argv[])
 {
@@ -79,11 +95,14 @@
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "cv";
+		static const char *short_options = "bce:rv";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
+			{"bigendian", no_argument, 0, 'b'},
 			{"content", no_argument, 0, 'c'},
+			{"endianconvert", required_argument, 0, 'e'},
+			{"recalccrc", required_argument, 0, 'r'},
 			{"verbose", no_argument, 0, 'v'},
 			{0, 0, 0, 0},
 		};
@@ -108,9 +127,19 @@
 		case 'v':
 			verbose = 1;
 			break;
+		case 'b':
+			bigendian = 1;
+			break;
 		case 'c':
 			dumpcontent = 1;
 			break;
+		case 'e':
+			convertendian = 1;
+			strcpy (cnvfile, optarg);
+			break;
+		case 'r':
+			recalccrc = 1;
+			break;
 		case '?':
 			error = 1;
 			break;
@@ -129,43 +158,101 @@
  */
 void do_dumpcontent (void) 
 {
-	char	*p = data;
-	union jffs2_node_union *node;
-	int	empty = 0, dirty = 0;
-	char	name[256];
+	char			*p = data;
+	union jffs2_node_union 	*node;
+	int			empty = 0, dirty = 0;
+	char			name[256];
+	uint32_t		crc;
 
 	while ( p < (data + imglen)) {
 		node = (union jffs2_node_union*) p;
+		
+		/* Skip empty space */
+		if (de16_to_cpu (node->u.magic) == 0xFFFF && de16_to_cpu (node->u.nodetype) == 0xFFFF) {
+			p += 4;
+			empty += 4;
+			continue;
+		}
+		
+		if (de16_to_cpu (node->u.magic) != JFFS2_MAGIC_BITMASK)	{
+			printf ("Wrong bitmask  at  0x%08x, 0x%04x\n", p - data, de16_to_cpu (node->u.magic));
+			p += 4;
+			dirty += 4;
+			continue;
+		}
+
+		crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
+		if (crc != de32_to_cpu (node->u.hdr_crc)) {
+			printf ("Wrong hdr_crc  at  0x%08x, 0x%08x instead of 0x%08x\n", p - data, de32_to_cpu (node->u.hdr_crc), crc);
+			p += 4;
+			dirty += 4;
+			continue;
+		}
 
-		switch(je16_to_cpu(node->u.nodetype)) {
+		switch(de16_to_cpu(node->u.nodetype)) {
+		
 		case JFFS2_NODETYPE_INODE:
 			printf ("Inode      node at 0x%08x, totlen 0x%08x, #ino  %5d, version %5d, isize %8d, csize %8d, dsize %8d, offset %8d\n",
-					p - data, je32_to_cpu (node->i.totlen), je32_to_cpu (node->i.ino),
-					je32_to_cpu ( node->i.version), je32_to_cpu (node->i.isize), 
-					je32_to_cpu (node->i.csize), je32_to_cpu (node->i.dsize), je32_to_cpu (node->i.offset));
-			p += PAD(je32_to_cpu (node->i.totlen));						
+					p - data, de32_to_cpu (node->i.totlen), de32_to_cpu (node->i.ino),
+					de32_to_cpu ( node->i.version), de32_to_cpu (node->i.isize), 
+					de32_to_cpu (node->i.csize), de32_to_cpu (node->i.dsize), de32_to_cpu (node->i.offset));
+
+			crc = crc32 (0, node, sizeof (struct jffs2_raw_inode) - 8);
+			if (crc != de32_to_cpu (node->i.node_crc)) {
+				printf ("Wrong node_crc at  0x%08x, 0x%08x instead of 0x%08x\n", p - data, de32_to_cpu (node->i.node_crc), crc);
+				p += PAD(de32_to_cpu (node->i.totlen));
+				dirty += PAD(de32_to_cpu (node->i.totlen));;
+				continue;
+			}
+			
+			crc = crc32(0, p + sizeof (struct jffs2_raw_inode), de32_to_cpu(node->i.csize));
+			if (crc != de32_to_cpu(node->i.data_crc)) {
+				printf ("Wrong data_crc at  0x%08x, 0x%08x instead of 0x%08x\n", p - data, de32_to_cpu (node->i.data_crc), crc);
+				p += PAD(de32_to_cpu (node->i.totlen));
+				dirty += PAD(de32_to_cpu (node->i.totlen));;
+				continue;
+			}
+
+			p += PAD(de32_to_cpu (node->i.totlen));
 			break;
 				
 		case JFFS2_NODETYPE_DIRENT:
 			memcpy (name, node->d.name, node->d.nsize);
 			name [node->d.nsize] = 0x0;
 			printf ("Dirent     node at 0x%08x, totlen 0x%08x, #pino %5d, version %5d, #ino  %8d, nsize %8d, name %s\n",
-					p - data, je32_to_cpu (node->d.totlen), je32_to_cpu (node->d.pino),
-					je32_to_cpu ( node->d.version), je32_to_cpu (node->d.ino), 
+					p - data, de32_to_cpu (node->d.totlen), de32_to_cpu (node->d.pino),
+					de32_to_cpu ( node->d.version), de32_to_cpu (node->d.ino), 
 					node->d.nsize, name);
-			p += PAD(je32_to_cpu (node->d.totlen));						
+
+			crc = crc32 (0, node, sizeof (struct jffs2_raw_dirent) - 8);
+			if (crc != de32_to_cpu (node->d.node_crc)) {
+				printf ("Wrong node_crc at  0x%08x, 0x%08x instead of 0x%08x\n", p - data, de32_to_cpu (node->d.node_crc), crc);
+				p += PAD(de32_to_cpu (node->d.totlen));
+				dirty += PAD(de32_to_cpu (node->d.totlen));;
+				continue;
+			}
+			
+			crc = crc32(0, p + sizeof (struct jffs2_raw_dirent), node->d.nsize);
+			if (crc != de32_to_cpu(node->d.name_crc)) {
+				printf ("Wrong name_crc at  0x%08x, 0x%08x instead of 0x%08x\n", p - data, de32_to_cpu (node->d.name_crc), crc);
+				p += PAD(de32_to_cpu (node->d.totlen));
+				dirty += PAD(de32_to_cpu (node->d.totlen));;
+				continue;
+			}
+
+			p += PAD(de32_to_cpu (node->d.totlen));						
 			break;
 	
 		case JFFS2_NODETYPE_CLEANMARKER:
 			if (verbose)
-				printf ("Cleanmarker     at 0x%08x, totlen 0x%08x\n", p - data, je32_to_cpu (node->u.totlen));
-			p += PAD(je32_to_cpu (node->u.totlen));						
+				printf ("Cleanmarker     at 0x%08x, totlen 0x%08x\n", p - data, de32_to_cpu (node->u.totlen));
+			p += PAD(de32_to_cpu (node->u.totlen));						
 			break;
 	
 		case JFFS2_NODETYPE_PADDING:
 			if (verbose)
-				printf ("Padding    node at 0x%08x, totlen 0x%08x\n", p - data, je32_to_cpu (node->u.totlen));
-			p += PAD(je32_to_cpu (node->u.totlen));						
+				printf ("Padding    node at 0x%08x, totlen 0x%08x\n", p - data, de32_to_cpu (node->u.totlen));
+			p += PAD(de32_to_cpu (node->u.totlen));						
 			break;
 			
 		case 0xffff:
@@ -175,9 +262,9 @@
 			
 		default:	
 			if (verbose)
-				printf ("Unknown    node at 0x%08x, totlen 0x%08x\n", p - data, je32_to_cpu (node->u.totlen));
-			p += PAD(je32_to_cpu (node->u.totlen));						
-			dirty += PAD(je32_to_cpu (node->u.totlen));						
+				printf ("Unknown    node at 0x%08x, totlen 0x%08x\n", p - data, de32_to_cpu (node->u.totlen));
+			p += PAD(de32_to_cpu (node->u.totlen));						
+			dirty += PAD(de32_to_cpu (node->u.totlen));						
 	
 		}
 	}
@@ -185,6 +272,141 @@
 	if (verbose)
 		printf ("Empty space: %d, dirty space: %d\n", empty, dirty);
 }
+
+/*
+ *	Convert endianess
+ */
+void do_endianconvert (void) 
+{
+	char			*p = data;
+	union jffs2_node_union 	*node, newnode;
+	int			fd, len;
+	jint32_t		mode;
+	uint32_t		crc;
+	
+	fd = open (cnvfile, O_WRONLY | O_CREAT, 0644);
+	if (fd < 0) {
+		fprintf (stderr, "Cannot open / create file: %s\n", cnvfile);
+		return;
+	}	
+
+	while ( p < (data + imglen)) {
+		node = (union jffs2_node_union*) p;
+
+		/* Skip empty space */
+		if (de16_to_cpu (node->u.magic) == 0xFFFF && de16_to_cpu (node->u.nodetype) == 0xFFFF) {
+			write (fd, p, 4);
+			p += 4;
+			continue;
+		}
+		
+		if (de16_to_cpu (node->u.magic) != JFFS2_MAGIC_BITMASK)	{
+			printf ("Wrong bitmask  at  0x%08x, 0x%04x\n", p - data, de16_to_cpu (node->u.magic));
+			newnode.u.magic = cnv_e16 (node->u.magic);			
+			newnode.u.nodetype = cnv_e16 (node->u.nodetype);
+			write (fd, &newnode, 4);
+			p += 4;
+			continue;
+		}
+
+		crc = crc32 (0, node, sizeof (struct jffs2_unknown_node) - 4);
+		if (crc != de32_to_cpu (node->u.hdr_crc)) {
+			printf ("Wrong hdr_crc  at  0x%08x, 0x%08x instead of 0x%08x\n", p - data, de32_to_cpu (node->u.hdr_crc), crc);
+		}
+
+		switch(de16_to_cpu(node->u.nodetype)) {
+
+		case JFFS2_NODETYPE_INODE:
+
+			newnode.i.magic = cnv_e16 (node->i.magic);			
+			newnode.i.nodetype = cnv_e16 (node->i.nodetype);
+			newnode.i.totlen = cnv_e32 (node->i.totlen);
+			newnode.i.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
+			newnode.i.ino = cnv_e32 (node->i.ino);
+			newnode.i.version = cnv_e32 (node->i.version);
+			mode.v32 = node->i.mode.m;
+			mode = cnv_e32 (mode);
+			newnode.i.mode.m = mode.v32;
+			newnode.i.uid = cnv_e16 (node->i.uid);
+			newnode.i.gid = cnv_e16 (node->i.gid);
+			newnode.i.isize = cnv_e32 (node->i.isize);
+			newnode.i.atime = cnv_e32 (node->i.atime);
+			newnode.i.mtime = cnv_e32 (node->i.mtime);
+			newnode.i.ctime = cnv_e32 (node->i.ctime);
+			newnode.i.offset = cnv_e32 (node->i.offset);
+			newnode.i.csize = cnv_e32 (node->i.csize);
+			newnode.i.dsize = cnv_e32 (node->i.dsize);
+			newnode.i.compr = node->i.compr;
+			newnode.i.usercompr = node->i.usercompr;
+			newnode.i.flags = cnv_e16 (node->i.flags);
+			if (recalccrc) {
+				len = de32_to_cpu(node->i.csize);
+				newnode.i.data_crc = cpu_to_e32 ( crc32(0, p + sizeof (struct jffs2_raw_inode), len));
+			} else
+				newnode.i.data_crc = cnv_e32 (node->i.data_crc);
+			
+			newnode.i.node_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_raw_inode) - 8));
+			
+			write (fd, &newnode, sizeof (struct jffs2_raw_inode));
+			write (fd, p + sizeof (struct jffs2_raw_inode), PAD (de32_to_cpu (node->i.totlen) -  sizeof (struct jffs2_raw_inode)));
+
+			p += PAD(de32_to_cpu (node->i.totlen));						
+			break;
+				
+		case JFFS2_NODETYPE_DIRENT:
+			newnode.d.magic = cnv_e16 (node->d.magic);
+			newnode.d.nodetype = cnv_e16 (node->d.nodetype);
+			newnode.d.totlen = cnv_e32 (node->d.totlen);
+			newnode.d.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
+			newnode.d.pino = cnv_e32 (node->d.pino);
+			newnode.d.version = cnv_e32 (node->d.version);
+			newnode.d.ino = cnv_e32 (node->d.ino);
+			newnode.d.mctime = cnv_e32 (node->d.mctime);
+			newnode.d.nsize = node->d.nsize;
+			newnode.d.type = node->d.type;
+			newnode.d.unused[0] = node->d.unused[0];
+			newnode.d.unused[1] = node->d.unused[1];
+			newnode.d.node_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_raw_dirent) - 8));
+			if (recalccrc)
+				newnode.d.name_crc = cpu_to_e32 ( crc32(0, p + sizeof (struct jffs2_raw_dirent), node->d.nsize));
+			else
+				newnode.d.name_crc = cnv_e32 (node->d.name_crc);
+
+			write (fd, &newnode, sizeof (struct jffs2_raw_dirent));
+			write (fd, p + sizeof (struct jffs2_raw_dirent), PAD (de32_to_cpu (node->d.totlen) -  sizeof (struct jffs2_raw_dirent)));
+			p += PAD(de32_to_cpu (node->d.totlen));						
+			break;
+	
+		case JFFS2_NODETYPE_CLEANMARKER:
+		case JFFS2_NODETYPE_PADDING:
+			newnode.u.magic = cnv_e16 (node->u.magic);
+			newnode.u.nodetype = cnv_e16 (node->u.nodetype);
+			newnode.u.totlen = cnv_e32 (node->u.totlen);
+			newnode.u.hdr_crc = cpu_to_e32 (crc32 (0, &newnode, sizeof (struct jffs2_unknown_node) - 4));
+			
+			write (fd, &newnode, sizeof (struct jffs2_unknown_node));
+			len = PAD(de32_to_cpu (node->u.totlen) - sizeof (struct jffs2_unknown_node));
+			if (len > 0) 
+				write (fd, p + sizeof (struct jffs2_unknown_node), len);
+				
+			p += PAD(de32_to_cpu (node->u.totlen));						
+			break;
+	
+		case 0xffff:
+			write (fd, p, 4);
+			p += 4;
+			break;
+			
+		default:	
+			printf ("Unknown node type: 0x%04x at 0x%08x, totlen 0x%08x\n", de16_to_cpu (node->u.nodetype), p - data, de32_to_cpu (node->u.totlen));
+			p += PAD(de32_to_cpu (node->u.totlen));
+				
+		}
+	}
+
+	close (fd);
+
+}
 	
 /*
  * Main program
@@ -221,6 +443,8 @@
 	if (dumpcontent)
 		do_dumpcontent ();
 
+	if (convertendian)
+		do_endianconvert ();
 	
 	// free memory
 	free (data);

Index: Makefile
===================================================================
RCS file: /home/cvs/mtd/util/Makefile,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- Makefile	8 Mar 2003 21:13:26 -0000	1.30
+++ Makefile	30 Apr 2003 15:13:00 -0000	1.31
@@ -3,7 +3,7 @@
 
 # $Id$
 
-# CROSS=arm-linux-
+#CROSS=arm-linux-
 CC := $(CROSS)gcc
 CFLAGS += -I../include -O2 -Wall -Wstrict-prototypes -Wshadow
 
@@ -32,4 +32,6 @@
 jffs2reader: jffs2reader.o
 	$(CC) $(LDFLAGS) -o $@ $^ -lz 
 
+jffs2dump: jffs2dump.o crc32.o
+	$(CC) $(LDFLAGS) -o $@ $^
 


