*** empty log message ***
[yaffs2.git] / yaffs_mtdif2.c
index 9ddf799b9044b100d4ddd48f1e6dbd4fa68573e2..9cf9828ed749e8d30dc6b039c226f6e33f5f020e 100644 (file)
 
 // mtd interface for YAFFS2
 
-const char *yaffs_mtdif2_c_version = "$Id: yaffs_mtdif2.c,v 1.1 2004-12-17 04:39:04 charles Exp $";
-
-#ifdef CONFIG_YAFFS_MTD_ENABLED
+const char *yaffs_mtdif2_c_version = "$Id: yaffs_mtdif2.c,v 1.6 2005-08-01 20:52:35 luc Exp $";
  
 #include "yportenv.h"
 
+#ifdef CONFIG_YAFFS_YAFFS1
+
 #include "yaffs_mtdif2.h"
 
 #include "linux/mtd/mtd.h"
@@ -43,14 +43,13 @@ int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __
 
        yaffs_PackedTags2 pt;
        
-       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %08x tags %08x" TENDSTR),chunkInNAND,data,tags));      
+       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p" TENDSTR),chunkInNAND,data,tags));  
 
        if(tags)
        {
                yaffs_PackTags2(&pt,tags);
        }
 
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        if(data && tags)
        {
                if(dev->useNANDECC)
@@ -60,15 +59,12 @@ int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __
        }
        else
        {
-#endif
        if(data)
                retval = mtd->write(mtd,addr,dev->nBytesPerChunk,&dummy,data);
        if(tags)
                retval = mtd->write_oob(mtd,addr,mtd->oobsize,&dummy,(__u8 *)&pt);
                
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        }
-#endif
 
     if (retval == 0)
        return YAFFS_OK;
@@ -87,9 +83,8 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *
        
        yaffs_PackedTags2 pt;
 
-       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_ReadChunkWithTagsToNAND chunk %d data %08x tags %08x" TENDSTR),chunkInNAND,data,tags));       
+       T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_ReadChunkWithTagsToNAND chunk %d data %p tags %p" TENDSTR),chunkInNAND,data,tags));   
 
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        if(data && tags)
        {
                if(dev->useNANDECC)
@@ -103,14 +98,11 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *
        }
        else
        {
-#endif
        if(data)
                retval = mtd->read(mtd,addr,dev->nBytesPerChunk,&dummy,data);
        if(tags)
                retval = mtd->read_oob(mtd,addr,mtd->oobsize,&dummy,dev->spareBuffer);
-#ifndef        CONFIG_YAFFS_USE_OLD_MTD
        }
-#endif
 
     memcpy(&pt,dev->spareBuffer,sizeof(pt));
     
@@ -130,7 +122,7 @@ int nandmtd2_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
        T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_MarkNANDBlockBad %d" TENDSTR),blockNo));      
        
        
-       retval = mtd->block_markbad(mtd,blockNo);
+       retval = mtd->block_markbad(mtd,blockNo * dev->nChunksPerBlock * dev->nBytesPerChunk);
 
     if (retval == 0)
        return YAFFS_OK;
@@ -145,7 +137,7 @@ int nandmtd2_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_B
        int retval;
        
        T(YAFFS_TRACE_MTD,(TSTR("nandmtd2_QueryNANDBlock %d" TENDSTR),blockNo));        
-       retval = mtd->block_isbad(mtd,blockNo);
+       retval = mtd->block_isbad(mtd,blockNo* dev->nChunksPerBlock * dev->nBytesPerChunk);
        
        if(retval)
        {