yaffs direct: Modify lseek value checking
[yaffs2.git] / direct / yaffs_nandif.c
index 8a8f3fb..9a22f7f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2007 Aleph One Ltd.
+ * Copyright (C) 2002-2010 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
@@ -13,7 +13,6 @@
 
 #include "yportenv.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 
 
 #include "yaffs_nandif.h"
  * We assume that the data buffer is of size totalBytersPerChunk so that we can also
  * use it to load the tags.
  */
-int ynandif_WriteChunkWithTagsToNAND(yaffs_dev_t * dev, int nand_chunk,
-                                     const __u8 * data,
-                                     const yaffs_ext_tags * tags)
+int ynandif_WriteChunkWithTagsToNAND(struct yaffs_dev * dev, int nand_chunk,
+                                     const u8 * data,
+                                     const struct yaffs_ext_tags * tags)
 {
 
        int retval = 0;
-       yaffs_PackedTags2 pt;
+       struct yaffs_packed_tags2 pt;
        void *spare;
        unsigned spareSize = 0;
        ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driver_context);
@@ -52,16 +51,16 @@ int ynandif_WriteChunkWithTagsToNAND(yaffs_dev_t * dev, int nand_chunk,
         */
 
        if(dev->param.inband_tags){
-               yaffs_PackedTags2TagsPart *pt2tp;
-               pt2tp = (yaffs_PackedTags2TagsPart *)(data + dev->data_bytes_per_chunk);
-               yaffs_PackTags2TagsPart(pt2tp,tags);
+               struct yaffs_packed_tags2_tags_only *pt2tp;
+               pt2tp = (struct yaffs_packed_tags2_tags_only *)(data + dev->data_bytes_per_chunk);
+               yaffs_pack_tags2_tags_only(pt2tp,tags);
                spare = NULL;
                spareSize = 0;
        }
        else{
-               yaffs_PackTags2(&pt, tags,!dev->param.no_tags_ecc);
+               yaffs_pack_tags2(&pt, tags,!dev->param.no_tags_ecc);
                spare = &pt;
-               spareSize = sizeof(yaffs_PackedTags2);
+               spareSize = sizeof(struct yaffs_packed_tags2);
        }
        
        retval = geometry->writeChunk(dev,nand_chunk,
@@ -70,10 +69,10 @@ int ynandif_WriteChunkWithTagsToNAND(yaffs_dev_t * dev, int nand_chunk,
        return retval;
 }
 
-int ynandif_ReadChunkWithTagsFromNAND(yaffs_dev_t * dev, int nand_chunk,
-                                      __u8 * data, yaffs_ext_tags * tags)
+int ynandif_ReadChunkWithTagsFromNAND(struct yaffs_dev * dev, int nand_chunk,
+                                      u8 * data, struct yaffs_ext_tags * tags)
 {
-       yaffs_PackedTags2 pt;
+       struct yaffs_packed_tags2 pt;
        int localData = 0;
        void *spare = NULL;
        unsigned spareSize;
@@ -100,7 +99,7 @@ int ynandif_ReadChunkWithTagsFromNAND(yaffs_dev_t * dev, int nand_chunk,
        }
        else {
                spare = &pt;
-               spareSize = sizeof(yaffs_PackedTags2);
+               spareSize = sizeof(struct yaffs_packed_tags2);
        }
 
        retval = geometry->readChunk(dev,nand_chunk,
@@ -111,9 +110,9 @@ int ynandif_ReadChunkWithTagsFromNAND(yaffs_dev_t * dev, int nand_chunk,
 
        if(dev->param.inband_tags){
                if(tags){
-                       yaffs_PackedTags2TagsPart * pt2tp;
-                       pt2tp = (yaffs_PackedTags2TagsPart *)&data[dev->data_bytes_per_chunk];  
-                       yaffs_unpack_tags2tags_part(tags,pt2tp);
+                       struct yaffs_packed_tags2_tags_only * pt2tp;
+                       pt2tp = (struct yaffs_packed_tags2_tags_only *)&data[dev->data_bytes_per_chunk];        
+                       yaffs_unpack_tags2_tags_only(tags,pt2tp);
                }
        }
        else {
@@ -139,14 +138,14 @@ int ynandif_ReadChunkWithTagsFromNAND(yaffs_dev_t * dev, int nand_chunk,
        return retval;
 }
 
-int ynandif_MarkNANDBlockBad(struct yaffs_dev_s *dev, int blockId)
+int ynandif_MarkNANDBlockBad(struct yaffs_dev *dev, int blockId)
 {
        ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driver_context);
 
        return geometry->markBlockBad(dev,blockId);
 }
 
-int ynandif_EraseBlockInNAND(struct yaffs_dev_s *dev, int blockId)
+int ynandif_EraseBlockInNAND(struct yaffs_dev *dev, int blockId)
 {
        ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driver_context);
 
@@ -155,17 +154,17 @@ int ynandif_EraseBlockInNAND(struct yaffs_dev_s *dev, int blockId)
 }
 
 
-static int ynandif_IsBlockOk(struct yaffs_dev_s *dev, int blockId)
+static int ynandif_IsBlockOk(struct yaffs_dev *dev, int blockId)
 {
        ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driver_context);
 
        return geometry->checkBlockOk(dev,blockId);
 }
 
-int ynandif_QueryNANDBlock(struct yaffs_dev_s *dev, int blockId, yaffs_block_state_t *state, __u32 *seq_number)
+int ynandif_QueryNANDBlock(struct yaffs_dev *dev, int blockId, enum yaffs_block_state *state, u32 *seq_number)
 {
        unsigned chunkNo;
-       yaffs_ext_tags tags;
+       struct yaffs_ext_tags tags;
 
        *seq_number = 0;
        
@@ -193,7 +192,7 @@ int ynandif_QueryNANDBlock(struct yaffs_dev_s *dev, int blockId, yaffs_block_sta
 }
 
 
-int ynandif_InitialiseNAND(yaffs_dev_t *dev)
+int ynandif_InitialiseNAND(struct yaffs_dev *dev)
 {
        ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driver_context);
 
@@ -202,7 +201,7 @@ int ynandif_InitialiseNAND(yaffs_dev_t *dev)
        return YAFFS_OK;
 }
 
-int ynandif_Deinitialise_flash_fn(yaffs_dev_t *dev)
+int ynandif_Deinitialise_flash_fn(struct yaffs_dev *dev)
 {
        ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driver_context);
 
@@ -212,15 +211,15 @@ int ynandif_Deinitialise_flash_fn(yaffs_dev_t *dev)
 }
 
 
-struct yaffs_dev_s * 
+struct yaffs_dev * 
        yaffs_add_dev_from_geometry(const YCHAR *name,
                                        const ynandif_Geometry *geometry)
 {
        YCHAR *clonedName = YMALLOC(sizeof(YCHAR) * (yaffs_strnlen(name,YAFFS_MAX_NAME_LENGTH)+1));
-       struct yaffs_dev_s *dev = YMALLOC(sizeof(struct yaffs_dev_s));
+       struct yaffs_dev *dev = YMALLOC(sizeof(struct yaffs_dev));
 
        if(dev && clonedName){
-               memset(dev,0,sizeof(struct yaffs_dev_s));
+               memset(dev,0,sizeof(struct yaffs_dev));
                yaffs_strcpy(clonedName,name);
 
                dev->param.name = clonedName;