diff -uNr mtd-19990809/Makefile mtd-19990810/Makefile
--- mtd-19990809/Makefile	Mon Aug  9 19:37:27 1999
+++ mtd-19990810/Makefile	Tue Aug 10 15:29:59 1999
@@ -1,20 +1,14 @@
-# $Id: Makefile,v 1.5 1999/08/09 18:37:27 dwmw2 Exp $
+# $Id: Makefile,v 1.7 1999/08/10 14:29:59 dwmw2 Exp $
 
-TARGETS = ffs2
-SUBDIRS = kernel util # boot
+TARGETS = ffs2 kernel
+SUBDIRS = util # boot
 
-all:	$(TARGETS)
+all:	
+	make -C /usr/src/linux SUBDIRS=$(shell pwd)/ffs2 modules
+	make -C /usr/src/linux SUBDIRS=$(shell pwd)/kernel modules
 	for a in $(SUBDIRS); do \
 		make -C $$a; \
 	done
-
-ffs2: ffs2/ffs2.o
-
-ffs2/ffs2.o: $(wildcard ffs2/*.[ch])
-	make -C /usr/src/linux SUBDIRS=$(shell pwd)/ffs2 modules
-
-kernel:
-	make -C kernel
 
 util:
 	make -C util
diff -uNr mtd-19990809/ffs2/makefile mtd-19990810/ffs2/makefile
--- mtd-19990809/ffs2/makefile	Mon Jul 26 22:49:34 1999
+++ mtd-19990810/ffs2/makefile	Tue Aug 10 15:11:59 1999
@@ -3,7 +3,7 @@
 
 O_TARGET := ffs2.o
 O_OBJS   := super.o io.o
-M_OBJS   := $(O_TARGET)
+MI_OBJS   := $(O_TARGET)
 	    
 include $(TOPDIR)/Rules.make
 	    
diff -uNr mtd-19990809/jgg/mtd/Makefile mtd-19990810/jgg/mtd/Makefile
--- mtd-19990809/jgg/mtd/Makefile	Tue Jul 27 17:56:44 1999
+++ mtd-19990810/jgg/mtd/Makefile	Thu Jan  1 01:00:00 1970
@@ -1,38 +0,0 @@
-# Sorry for this mess :|
-
-CFLAGS=-DMODULE -D__KERNEL__ -Wall -I/usr/local/src/linux/include -I.. -I. -O2
-VPATH=devices/:ffs2/:bin/
-
-all: modules/mtd.o modules/octagon-5066.o modules/mixmem.o modules/vmax301.o \
-     modules/ffs2.o bin/mkfs.ffs2 bin/erase
-
-# Bulk modules
-modules/mtd.o: devices/mtd-base.o devices/mapped.o
-	ld -m elf_i386  -r -o $@ $(filter %.o,$^)
-modules/ffs2.o: ffs2/super.o ffs2/io.o
-	ld -m elf_i386  -r -o $@ $(filter %.o,$^)
-
-bin/mkfs.ffs2: bin/mkfs.ffs2.o
-	gcc -o $@ $^
-
-bin/erase: bin/erase.o
-	gcc -o $@ $^
-
-# Individual things
-devices/mtd-base.o: mtd-base.c mtd.h
-devices/mapped.o: mapped.c mapped.h mtd.h
-modules/octagon-5066.o: octagon-5066.c mtd.h mapped.h
-modules/mixmem.o: mixmem.c mtd.h mapped.h
-modules/vmax301.o: vmax301.c mtd.h mapped.h
-modules/ffs2.o: super.c ffs2_fs.h ffs2_fs_i.h ffs2_fs_sb.h io.h
-bin/mkfs.ffs2.o: mkfs.ffs2.c ffs2_fs.h local.h
-ffs2/io.o: io.c ffs2_fs.h ffs2_fs_i.h ffs2_fs_sb.h io.h local.h
-
-# Some magical compile rules...
-modules/%.o: devices/%.c
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
-modules/%.o: ffs2/%.c
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@	
-	
-clean:
-	rm -f *.o
diff -uNr mtd-19990809/kernel/Makefile mtd-19990810/kernel/Makefile
--- mtd-19990809/kernel/Makefile	Mon Aug  9 20:38:05 1999
+++ mtd-19990810/kernel/Makefile	Tue Aug 10 15:11:59 1999
@@ -1,15 +1,25 @@
-# $Id: Makefile,v 1.4 1999/08/09 19:38:05 dwmw2 Exp $
+# $Id: Makefile,v 1.6 1999/08/10 14:00:04 dwmw2 Exp $
 
-CFLAGS=-DMODULE -D__KERNEL__ -I/usr/src/linux/include -I../include -O2
+EXTRA_CFLAGS= -I$(shell pwd)/../include
 
-TARGETS = mtd.o slram.o ftl.o doc1000.o doc2000.o mtdblock.o mapped.o \
-	vmax301.o octagon-5066.o nftl.o
+HWDRIVERS = slram.o doc1000.o doc2000.o vmax301.o octagon-5066.o
+USERDRIVERS = ftl.o nftl.o mtdblock.o
 
-all : $(TARGETS)
+MIX_OBJS = mtd.o mapped.o
+MI_OBJS = $(HWDRIVERS) $(USERDRIVERS)
+
+include $(TOPDIR)/Rules.make
+
+
+
+#all : $(TARGETS)
+
+#flashcard.o mtd.o physmem.o ftl.o: ../include/mtd.h
+#ftl.o: ../include/ftl.h	ftl.c
+#flashcard.o: ../include/iflash.h flashcard.c
+
+#clean:
+
+#	rm -f $(TARGETS) $(wildcard ffs2/*.o)
 
-flashcard.o mtd.o physmem.o ftl.o: ../include/mtd.h
-ftl.o: ../include/ftl.h	ftl.c
-flashcard.o: ../include/iflash.h flashcard.c
 
-clean:
-	rm -f $(TARGETS) $(wildcard ffs2/*.o)
diff -uNr mtd-19990809/kernel/mapped.c mtd-19990810/kernel/mapped.c
--- mtd-19990809/kernel/mapped.c	Mon Aug  9 19:32:14 1999
+++ mtd-19990810/kernel/mapped.c	Tue Aug 10 15:11:59 1999
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                          /*{{{*/
-// $Id: mapped.c,v 1.2 1999/08/09 18:32:14 dwmw2 Exp $
+// $Id: mapped.c,v 1.3 1999/08/10 14:00:04 dwmw2 Exp $
 /* ######################################################################
 
    Flash MTD Routines
@@ -15,6 +15,11 @@
 									/*}}}*/
 #include "mapped.h"
 
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
 #include <asm/io.h>
 #include <asm/delay.h>
 
diff -uNr mtd-19990809/kernel/nftl.c mtd-19990810/kernel/nftl.c
--- mtd-19990809/kernel/nftl.c	Mon Aug  9 20:38:05 1999
+++ mtd-19990810/kernel/nftl.c	Tue Aug 10 16:52:24 1999
@@ -2,7 +2,7 @@
 /* Linux driver for Disk-On-Chip 2000       */
 /* (c) 1999 Machine Vision Holdings, Inc.   */
 /* Author: David Woodhouse <dwmw2@mvhi.com> */
-/* $Id: nftl.c,v 1.1 1999/08/09 19:38:05 dwmw2 Exp $ */
+/* $Id: nftl.c,v 1.4 1999/08/10 15:52:24 dwmw2 Exp $ */
 
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -65,7 +65,7 @@
 
   /* OK, it's a new one. Set up all the data structures. */
 
-  printk("Found new NFTL at offset %lx\n",ofs);
+  printk("Found new NFTL nftl%c at offset %lx\n",numnftls + 'a', ofs);
 
   if (hdr->UnitSizeFactor != 0xff) {
     printk("Sorry, we don't support UnitSizeFactor of != 1 yet\n");
@@ -121,8 +121,9 @@
   /* Scan each physical Erase Unit for validity and to find the 
      Virtual Erase Unit Chain to which it belongs */
 
-  for (i=thisNFTL->MediaHdr.FirstPhysicalEUN; i < thisNFTL->numEUNs + 
-	 thisNFTL->MediaHdr.FirstPhysicalEUN; i++) {
+  for (i=le16_to_cpu(thisNFTL->MediaHdr.FirstPhysicalEUN); 
+       i < thisNFTL->numEUNs + 
+	 le16_to_cpu(thisNFTL->MediaHdr.FirstPhysicalEUN); i++) {
 
     union doc_uci uci;
     unsigned long ofs;
@@ -131,9 +132,10 @@
 
     MTD_READOOB(mtd, (i * thisNFTL->EraseSize) + 512 + 8, 8, &retlen, (char *)&uci);
 
-    if (uci.b.EraseMark != 0x3c69 || uci.b.EraseMark1 != 0x3c69) {
+    if (uci.b.EraseMark != cpu_to_le16(0x3c69) || 
+	uci.b.EraseMark1 != cpu_to_le16(0x3c69)) {
       printk("EUN %d: EraseMark not 0x3c69 (0x%4.4x 0x%4.4x instead)\n",
-	     i, uci.b.EraseMark, uci.b.EraseMark1);
+	     i, le16_to_cpu(uci.b.EraseMark), le16_to_cpu(uci.b.EraseMark1));
       continue;
     }
     
@@ -141,21 +143,23 @@
     
     if (uci.a.VirtUnitNum != uci.a.SpareVirtUnitNum)
       printk("EUN %d: VirtualUnitNumber (%x) != SpareVirtualUnitNumber (%x)\n",
-	     i, uci.a.VirtUnitNum, uci.a.SpareVirtUnitNum);
+	     i, le16_to_cpu(uci.a.VirtUnitNum), 
+	     le16_to_cpu(uci.a.SpareVirtUnitNum));
 
     if (uci.a.ReplUnitNum != uci.a.SpareReplUnitNum)
       printk("EUN %d: ReplacementUnitNumber (%x) != SpareReplacementUnitNumber (%x)\n",
-	     i, uci.a.ReplUnitNum, uci.a.SpareReplUnitNum);
+	     i, le16_to_cpu(uci.a.ReplUnitNum), 
+	     le16_to_cpu(uci.a.SpareReplUnitNum));
 
     /* We don't actually _do_ anything about the above, just whinge */
 
-    thisNFTL->VirtualUnitTable[i] = uci.a.VirtUnitNum;
-    thisNFTL->ReplUnitTable[i] = uci.a.ReplUnitNum;
+    thisNFTL->VirtualUnitTable[i] = le16_to_cpu(uci.a.VirtUnitNum);
+    thisNFTL->ReplUnitTable[i] = le16_to_cpu(uci.a.ReplUnitNum);
 
 
     /* if (!(VUN & 0x8000) && VUN < (arraybounds)).. optimises to: */
-    if (uci.a.VirtUnitNum < thisNFTL->numvunits) 
-      thisNFTL->EUNtable[uci.a.VirtUnitNum & 0x7fff] = i;
+    if (le16_to_cpu(uci.a.VirtUnitNum) < thisNFTL->numvunits) 
+      thisNFTL->EUNtable[le16_to_cpu(uci.a.VirtUnitNum) & 0x7fff] = i;
 
   } 
   NFTLs[numnftls++] = thisNFTL;
@@ -200,19 +204,22 @@
     if (!mtd) 
       continue;
 
-  for (ofs = 0; ofs < mtd->size ; ofs += mtd->erasesize)
-    {
-      size_t retlen;
-      MTD_READ(mtd, ofs, sizeof(hdr), &retlen, (u_char *)&hdr);
-
-      if (retlen < sizeof(hdr))
-	continue;
+    if (!mtd->read_oob) /* If this MTD doesn't have out-of-band data,
+			   then there's no point continuing */
+      continue;
 
-      if (!strncmp(hdr.DataOrgID, "ANAND", 6)) {
+    for (ofs = 0; ofs < mtd->size ; ofs += mtd->erasesize) {
+	size_t retlen;
+	MTD_READ(mtd, ofs, sizeof(hdr), &retlen, (u_char *)&hdr);
+	
+	if (retlen < sizeof(hdr))
+	  continue;
 	
-	NFTL_setup(mtd, ofs, &hdr);
+	if (!strncmp(hdr.DataOrgID, "ANAND", 6)) {
+	  
+	  NFTL_setup(mtd, ofs, &hdr);
+	}
       }
-    }
   }
 }
 
@@ -238,7 +245,6 @@
   struct NFTLrecord *thisNFTL;
   char *buffer;
 repeat:
-
   cli();
   INIT_REQUEST;
   dev = MINOR(CURRENT->rq_dev);
@@ -378,7 +384,7 @@
   
 
   printk("M-Systems NAND Flash Translation Layer driver.\n (C) 1999 Machine Vision Holdings, Inc.\n");
-  printk("$Id: nftl.c,v 1.1 1999/08/09 19:38:05 dwmw2 Exp $\n");
+  printk("$Id: nftl.c,v 1.4 1999/08/10 15:52:24 dwmw2 Exp $\n");
 
   NFTL_init();
   if (numnftls) {
@@ -395,11 +401,13 @@
 	nftl_blocksizes[i] = 1024;
       blksize_size[NFTL_MAJOR] = nftl_blocksizes;
       nftl_gendisk.next = gendisk_head;
-      gendisk_head = &nftl_gendisk;
-      resetup_one_dev(&nftl_gendisk, 0);
-      
+     gendisk_head = &nftl_gendisk;
     }
-    
+
+    for (i=0; i < numnftls ; i++) {
+      resetup_one_dev(&nftl_gendisk, i);
+    }
+
     return 0;
   }
   printk("No NFTL partitions found\n");
