*** empty log message ***
[yaffs2.git] / yaffs_mtdif.c
index 13df3d98a8faa7bd4b71b641606f6b445e994786..9537b1a509c568f55495160d5151a98fc5ec0579 100644 (file)
@@ -13,7 +13,7 @@
  *
  */
 
-const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.6 2005-07-31 08:38:41 marty Exp $";
+const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.9 2005-08-02 19:18:44 luc Exp $";
  
 #include "yportenv.h"
 
@@ -24,13 +24,13 @@ const char *yaffs_mtdif_c_version = "$Id: yaffs_mtdif.c,v 1.6 2005-07-31 08:38:4
 #include "linux/mtd/mtd.h"
 #include "linux/types.h"
 #include "linux/time.h"
-
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
 #include "linux/mtd/nand.h"
-#endif
 
 static struct nand_oobinfo yaffs_oobinfo = {
        .useecc = 1,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8))
+       .eccbytes = 6,
+#endif
        .eccpos = {8, 9, 10, 13, 14, 15}
 };
 
@@ -49,24 +49,20 @@ int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data,
        
        __u8 *spareAsBytes = (__u8 *)spare;
 
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        if(data && spare)
        {
                if(dev->useNANDECC)
-                       mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_oobinfo);
+                       retval = mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_oobinfo);
                else
-                       mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_noeccinfo);
+                       retval = mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_noeccinfo);
        }
        else
        {
-#endif
        if(data)
                retval = mtd->write(mtd,addr,dev->nBytesPerChunk,&dummy,data);
        if(spare)
                retval = mtd->write_oob(mtd,addr,YAFFS_BYTES_PER_SPARE,&dummy,spareAsBytes);
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        }
-#endif
 
     if (retval == 0)
        return YAFFS_OK;
@@ -84,7 +80,6 @@ int nandmtd_ReadChunkFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaf
        
        __u8 *spareAsBytes = (__u8 *)spare;
        
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        if(data && spare)
        {
                if(dev->useNANDECC)
@@ -99,14 +94,11 @@ int nandmtd_ReadChunkFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *data, yaf
        }
        else
        {
-#endif
        if(data)
                retval = mtd->read(mtd,addr,dev->nBytesPerChunk,&dummy,data);
        if(spare)
                retval = mtd->read_oob(mtd,addr,YAFFS_BYTES_PER_SPARE,&dummy,spareAsBytes);
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        }
-#endif
 
     if (retval == 0)
        return YAFFS_OK;