More driver cleanup
authorCharles Manning <cdhmanning@gmail.com>
Mon, 25 Jun 2012 00:01:42 +0000 (12:01 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 25 Jun 2012 00:01:42 +0000 (12:01 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
12 files changed:
direct/basic-test/Makefile
direct/basic-test/yaffs_fileem2k.c
direct/basic-test/yaffs_fileem2k.h
direct/basic-test/yaffs_m18_drv.c [moved from direct/basic-test/yaffs_norif1.c with 69% similarity]
direct/basic-test/yaffs_m18_drv.h [moved from direct/basic-test/yaffs_norif1.h with 82% similarity]
direct/basic-test/yaffscfg2k.c
yaffs_checkptrw.c
yaffs_guts.c
yaffs_guts.h
yaffs_nand.c
yaffs_tagscompat.c
yaffs_tagsmarshall.c

index b98af82..e90277d 100644 (file)
@@ -40,7 +40,7 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \
                 yaffs_packedtags2.o yaffs_nand.o \
                 yaffs_checkptrw.o  yaffs_qsort.o\
                 yaffs_nameval.o yaffs_attribs.o \
-                yaffs_norif1.o  ynorsim.o \
+                yaffs_m18_drv.o  ynorsim.o \
                 yaffs_allocator.o \
                 yaffs_bitmap.o \
                 yaffs_yaffs1.o \
index 53970cf..b9a00f1 100644 (file)
 #include <fcntl.h>
 #include <unistd.h>
 
+#if 1
+
+#define SIZE_IN_MB 32
+/* #define SIZE_IN_MB 128 */
+
+#define PAGE_DATA_SIZE (2048)
+#define PAGE_SPARE_SIZE  (64)
+#define PAGE_SIZE  (PAGE_DATA_SIZE + PAGE_SPARE_SIZE)
+#define PAGES_PER_BLOCK (64)
+#define BLOCK_DATA_SIZE (PAGE_DATA_SIZE * PAGES_PER_BLOCK)
+#define BLOCK_SIZE (PAGES_PER_BLOCK * (PAGE_SIZE))
+#define BLOCKS_PER_MB ((1024*1024)/BLOCK_DATA_SIZE)
+#define SIZE_IN_BLOCKS (BLOCKS_PER_MB * SIZE_IN_MB)
+
+#else
+
+#define SIZE_IN_MB 128
+#define PAGE_DATA_SIZE (512)
+#define SPARE_SIZE  (16)
+#define PAGE_SIZE  (PAGE_DATA_SIZE + SPARE_SIZE)
+#define PAGES_PER_BLOCK (32)
+#define BLOCK_DATA_SIZE (PAGE_SIZE * PAGES_PER_BLOCK)
+#define BLOCK_SIZE (PAGES_PER_BLOCK * (PAGE_SIZE))
+#define BLOCKS_PER_MB ((1024*1024)/BLOCK_DATA_SIZE)
+#define SIZE_IN_BLOCKS (BLOCKS_PER_MB * SIZE_IN_MB)
+
+#endif
+
 #define REPORT_ERROR 0
 
 typedef struct
@@ -319,10 +347,27 @@ static int yflash2_Initialise(struct yaffs_dev *dev)
        return YAFFS_OK;
 }
 
-void yflash2_install_drv(struct yaffs_dev *dev)
+struct yaffs_dev *yflash2_install_drv(const char *name)
 {
-       struct yaffs_param *param = &dev->param;
-       struct yaffs_driver *drv = &dev->drv;
+       struct yaffs_dev *dev = NULL;
+       struct yaffs_param *param;
+       struct yaffs_driver *drv;
+
+       dev = malloc(sizeof(*dev));
+
+       if(!dev)
+               return NULL;
+
+       memset(dev, 0, sizeof(*dev));
+
+       dev->param.name = strdup(name);
+
+       if(!dev->param.name) {
+               free(dev);
+               return NULL;
+       }
+
+       drv = &dev->drv;
 
        drv->drv_write_chunk_fn = yflash2_WriteChunk;
        drv->drv_read_chunk_fn = yflash2_ReadChunk;
@@ -331,6 +376,7 @@ void yflash2_install_drv(struct yaffs_dev *dev)
        drv->drv_check_bad_fn = yflash2_CheckBad;
        drv->drv_initialise_fn = yflash2_Initialise;
 
+       param = &dev->param;
 
        param->total_bytes_per_chunk = 2048;
        param->chunks_per_block = 64;
@@ -338,4 +384,17 @@ void yflash2_install_drv(struct yaffs_dev *dev)
        param->end_block = yflash2_GetNumberOfBlocks()-1;
        param->is_yaffs2 = 1;
        param->use_nand_ecc=1;
+
+       param->n_reserved_blocks = 5;
+       param->wide_tnodes_disabled=0;
+       param->refresh_period = 1000;
+       param->n_caches = 10; // Use caches
+
+       param->enable_xattr = 1;
+
+       /* dev->driver_context is not used by this simulator */
+
+       yaffs_add_device(dev);
+
+       return dev;
 }
index e447987..b7234c0 100644 (file)
 #ifndef __FILEEM2K_H__
 #define __FILEEM2K_H__
 
-#if 1
-
-#define SIZE_IN_MB 32
-/* #define SIZE_IN_MB 128 */
-
-#define PAGE_DATA_SIZE (2048)
-#define PAGE_SPARE_SIZE  (64)
-#define PAGE_SIZE  (PAGE_DATA_SIZE + PAGE_SPARE_SIZE)
-#define PAGES_PER_BLOCK (64)
-#define BLOCK_DATA_SIZE (PAGE_DATA_SIZE * PAGES_PER_BLOCK)
-#define BLOCK_SIZE (PAGES_PER_BLOCK * (PAGE_SIZE))
-#define BLOCKS_PER_MB ((1024*1024)/BLOCK_DATA_SIZE)
-#define SIZE_IN_BLOCKS (BLOCKS_PER_MB * SIZE_IN_MB)
-
-#else
-
-#define SIZE_IN_MB 128
-#define PAGE_DATA_SIZE (512)
-#define SPARE_SIZE  (16)
-#define PAGE_SIZE  (PAGE_DATA_SIZE + SPARE_SIZE)
-#define PAGES_PER_BLOCK (32)
-#define BLOCK_DATA_SIZE (PAGE_SIZE * PAGES_PER_BLOCK)
-#define BLOCK_SIZE (PAGES_PER_BLOCK * (PAGE_SIZE))
-#define BLOCKS_PER_MB ((1024*1024)/BLOCK_DATA_SIZE)
-#define SIZE_IN_BLOCKS (BLOCKS_PER_MB * SIZE_IN_MB)
-
-#endif
 
 struct yaffs_dev;
 
-void yflash2_install_drv(struct yaffs_dev *dev);
+struct yaffs_dev *yflash2_install_drv(const char *name);
 
 
 #endif
similarity index 69%
rename from direct/basic-test/yaffs_norif1.c
rename to direct/basic-test/yaffs_m18_drv.c
index d358a43..c35cb78 100644 (file)
@@ -35,7 +35,7 @@
  *
  */
 
-#include "yaffs_norif1.h"
+#include "yaffs_m18_drv.h"
 
 #include "yportenv.h"
 #include "yaffs_trace.h"
@@ -50,7 +50,8 @@
 #define CHUNKS_PER_BLOCK       248
 #define SPARE_AREA_OFFSET      (CHUNKS_PER_BLOCK * PROG_REGION_SIZE)
 
-#define FORMAT_OFFSET          (SPARE_AREA_OFFSET + CHUNKS_PER_BLOCK * (SPARE_BYTES_PER_CHUNK + M18_SKIP))
+#define FORMAT_OFFSET          (SPARE_AREA_OFFSET + CHUNKS_PER_BLOCK * \
+                               (SPARE_BYTES_PER_CHUNK + M18_SKIP))
 
 #define FORMAT_VALUE           0x1234
 
 
 /* Compile this for a simulation */
 #include "ynorsim.h"
-#define ynorif1_FlashInit() ynorsim_initialise()
-#define ynorif1_FlashDeinit() ynorsim_shutdown()
-#define ynorif1_FlashWrite32(addr,buf,nwords) ynorsim_wr32(addr,buf,nwords)
-#define ynorif1_FlashRead32(addr,buf,nwords) ynorsim_rd32(addr,buf,nwords)
-#define ynorif1_FlashEraseBlock(addr) ynorsim_erase(addr)
+#define m18_drv_FlashInit() ynorsim_initialise()
+#define m18_drv_FlashDeinit() ynorsim_shutdown()
+#define m18_drv_FlashWrite32(addr,buf,nwords) ynorsim_wr32(addr,buf,nwords)
+#define m18_drv_FlashRead32(addr,buf,nwords) ynorsim_rd32(addr,buf,nwords)
+#define m18_drv_FlashEraseBlock(addr) ynorsim_erase(addr)
 #define DEVICE_BASE     ynorsim_get_base()
 #else
 
-/* Compile this for running on blob, hacked for yaffs access */
+/* Compile this to hook up to read hardware */
 #include "../blob/yflashrw.h"
-#define ynorif1_FlashInit()  do{} while(0)
-#define ynorif1_FlashDeinit() do {} while(0)
-#define ynorif1_FlashWrite32(addr,buf,nwords) Y_FlashWrite(addr,buf,nwords)
-#define ynorif1_FlashRead32(addr,buf,nwords)  Y_FlashRead(addr,buf,nwords)
-#define ynorif1_FlashEraseBlock(addr)         Y_FlashErase(addr,BLOCK_SIZE_IN_BYTES)
+#define m18_drv_FlashInit()  do{} while(0)
+#define m18_drv_FlashDeinit() do {} while(0)
+#define m18_drv_FlashWrite32(addr,buf,nwords) Y_FlashWrite(addr,buf,nwords)
+#define m18_drv_FlashRead32(addr,buf,nwords)  Y_FlashRead(addr,buf,nwords)
+#define m18_drv_FlashEraseBlock(addr)         Y_FlashErase(addr,BLOCK_SIZE_IN_BYTES)
 #define DEVICE_BASE     (32 * 1024 * 1024)
 #endif
 
@@ -136,7 +137,7 @@ static u32 *Chunk2SpareAddr(struct yaffs_dev *dev,int chunk_id)
 }
 
 
-static void ynorif1_AndBytes(u8*target, const u8   *src, int nbytes)
+static void m18_drv_AndBytes(u8*target, const u8   *src, int nbytes)
 {
         while(nbytes > 0){
                 *target &= *src;
@@ -146,7 +147,7 @@ static void ynorif1_AndBytes(u8*target, const u8   *src, int nbytes)
         }
 }
 
-static int ynorif1_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,
+static int m18_drv_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,
                                    const u8 *data, int data_len,
                                    const u8 *oob, int oob_len)
 {
@@ -174,30 +175,30 @@ static int ynorif1_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,
                 /* Write a pre-marker */
                 memset(&tmpSpare,0xff,sizeof(tmpSpare));
                 tmpSpare.page_status = YNOR_PREMARKER;
-                ynorif1_FlashWrite32(spareAddr,(u32 *)&tmpSpare,sizeof(struct yaffs_spare)/4);
+                m18_drv_FlashWrite32(spareAddr,(u32 *)&tmpSpare,sizeof(struct yaffs_spare)/4);
 
                 /* Write the data */
-                ynorif1_FlashWrite32(dataAddr,(u32 *)data, data_len/ 4);
+                m18_drv_FlashWrite32(dataAddr,(u32 *)data, data_len/ 4);
 
 
                 memcpy(&tmpSpare,spare,sizeof(struct yaffs_spare));
 
                 /* Write the real tags, but override the premarker*/
                 tmpSpare.page_status = YNOR_PREMARKER;
-                ynorif1_FlashWrite32(spareAddr,(u32 *)&tmpSpare,sizeof(struct yaffs_spare)/4);
+                m18_drv_FlashWrite32(spareAddr,(u32 *)&tmpSpare,sizeof(struct yaffs_spare)/4);
 
                 /* Write a post-marker */
                 tmpSpare.page_status = YNOR_POSTMARKER;
-                ynorif1_FlashWrite32(spareAddr,(u32 *)&tmpSpare,sizeof(tmpSpare)/4);
+                m18_drv_FlashWrite32(spareAddr,(u32 *)&tmpSpare,sizeof(tmpSpare)/4);
 
         } else if(spare){
                 /* This has to be a read-modify-write operation to handle NOR-ness */
 
-                ynorif1_FlashRead32(spareAddr,(u32 *)&tmpSpare,16/ 4);
+                m18_drv_FlashRead32(spareAddr,(u32 *)&tmpSpare,16/ 4);
 
-                ynorif1_AndBytes((u8 *)&tmpSpare,(u8 *)spare,sizeof(struct yaffs_spare));
+                m18_drv_AndBytes((u8 *)&tmpSpare,(u8 *)spare,sizeof(struct yaffs_spare));
 
-                ynorif1_FlashWrite32(spareAddr,(u32 *)&tmpSpare,16/ 4);
+                m18_drv_FlashWrite32(spareAddr,(u32 *)&tmpSpare,16/ 4);
         }
         else {
                 BUG();
@@ -208,7 +209,7 @@ static int ynorif1_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,
 
 }
 
-static int ynorif1_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk,
+static int m18_drv_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk,
                                        u8 *data, int data_len,
                                        u8 *oob, int oob_len,
                                        enum yaffs_ecc_result *ecc_result)
@@ -220,12 +221,12 @@ static int ynorif1_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk,
 
        if(data)
        {
-               ynorif1_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / 4);
+               m18_drv_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / 4);
        }
 
         if(oob)
         {
-                ynorif1_FlashRead32(spareAddr,(u32 *)spare, oob_len/ 4);
+                m18_drv_FlashRead32(spareAddr,(u32 *)spare, oob_len/ 4);
 
                 /* If the page status is YNOR_POSTMARKER then it was written properly
                  * so change that to 0xFF so that the rest of yaffs is happy.
@@ -245,40 +246,40 @@ static int ynorif1_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk,
 }
 
 
-static int ynorif1_FormatBlock(struct yaffs_dev *dev, int blockNumber)
+static int m18_drv_FormatBlock(struct yaffs_dev *dev, int blockNumber)
 {
        u32 *blockAddr = Block2Addr(dev,blockNumber);
        u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
        u32 formatValue = FORMAT_VALUE;
 
-       ynorif1_FlashEraseBlock(blockAddr);
-       ynorif1_FlashWrite32(formatAddr,&formatValue,1);
+       m18_drv_FlashEraseBlock(blockAddr);
+       m18_drv_FlashWrite32(formatAddr,&formatValue,1);
 
        return YAFFS_OK;
 }
 
-static int ynorif1_UnformatBlock(struct yaffs_dev *dev, int blockNumber)
+static int m18_drv_UnformatBlock(struct yaffs_dev *dev, int blockNumber)
 {
        u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
        u32 formatValue = 0;
 
-       ynorif1_FlashWrite32(formatAddr,&formatValue,1);
+       m18_drv_FlashWrite32(formatAddr,&formatValue,1);
 
        return YAFFS_OK;
 }
 
-static int ynorif1_IsBlockFormatted(struct yaffs_dev *dev, int blockNumber)
+static int m18_drv_IsBlockFormatted(struct yaffs_dev *dev, int blockNumber)
 {
        u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
        u32 formatValue;
 
 
-       ynorif1_FlashRead32(formatAddr,&formatValue,1);
+       m18_drv_FlashRead32(formatAddr,&formatValue,1);
 
        return (formatValue == FORMAT_VALUE);
 }
 
-static int ynorif1_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
+static int m18_drv_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
 
        if(blockNumber < 0 || blockNumber >= BLOCKS_IN_DEVICE)
@@ -290,39 +291,57 @@ static int ynorif1_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
        }
        else
        {
-               ynorif1_UnformatBlock(dev,blockNumber);
-               ynorif1_FormatBlock(dev,blockNumber);
+               m18_drv_UnformatBlock(dev,blockNumber);
+               m18_drv_FormatBlock(dev,blockNumber);
                return YAFFS_OK;
        }
 
 }
 
-static int ynorif1_InitialiseNAND(struct yaffs_dev *dev)
+static int m18_drv_InitialiseNAND(struct yaffs_dev *dev)
 {
        int i;
 
-       ynorif1_FlashInit();
+       m18_drv_FlashInit();
        /* Go through the blocks formatting them if they are not formatted */
        for(i = dev->param.start_block; i <= dev->param.end_block; i++){
-               if(!ynorif1_IsBlockFormatted(dev,i)){
-                       ynorif1_FormatBlock(dev,i);
+               if(!m18_drv_IsBlockFormatted(dev,i)){
+                       m18_drv_FormatBlock(dev,i);
                }
        }
        return YAFFS_OK;
 }
 
-static int ynorif1_Deinitialise_flash_fn(struct yaffs_dev *dev)
+static int m18_drv_Deinitialise_flash_fn(struct yaffs_dev *dev)
 {
        dev=dev;
-       ynorif1_FlashDeinit();
+       m18_drv_FlashDeinit();
 
        return YAFFS_OK;
 }
 
-void ynorif1_install_drv(struct yaffs_dev *dev)
+
+struct yaffs_dev *yaffs_m18_install_drv(const char *name)
 {
-       struct yaffs_param *param = &dev->param;
-       struct yaffs_driver *drv = &dev->drv;
+
+       struct yaffs_dev *dev = malloc(sizeof(struct yaffs_dev));
+       char *name_copy = strdup(name);
+       struct yaffs_param *param;
+       struct yaffs_driver *drv;
+
+
+       if(!dev || !name_copy) {
+               free(name_copy);
+               free(dev);
+               return NULL;
+       }
+
+       param = &dev->param;
+       drv = &dev->drv;
+
+       memset(dev, 0, sizeof(*dev));
+
+       param->name = name_copy;
 
        param->total_bytes_per_chunk = 1024;
        param->chunks_per_block =248;
@@ -330,10 +349,17 @@ void ynorif1_install_drv(struct yaffs_dev *dev)
        param->start_block = 0; // Can use block 0
        param->end_block = 31; // Last block
        param->use_nand_ecc = 0; // use YAFFS's ECC
-       drv->drv_write_chunk_fn = ynorif1_WriteChunkToNAND;
-       drv->drv_read_chunk_fn = ynorif1_ReadChunkFromNAND;
-       drv->drv_erase_fn = ynorif1_EraseBlockInNAND;
-       drv->drv_initialise_fn = ynorif1_InitialiseNAND;
-       drv->drv_deinitialise_fn = ynorif1_Deinitialise_flash_fn;
-}
 
+       drv->drv_write_chunk_fn = m18_drv_WriteChunkToNAND;
+       drv->drv_read_chunk_fn = m18_drv_ReadChunkFromNAND;
+       drv->drv_erase_fn = m18_drv_EraseBlockInNAND;
+       drv->drv_initialise_fn = m18_drv_InitialiseNAND;
+       drv->drv_deinitialise_fn = m18_drv_Deinitialise_flash_fn;
+
+       param->n_caches = 10;
+       param->disable_soft_del = 1;
+
+       dev->driver_context = (void *) 1;       // Used to identify the device in fstat.
+
+       yaffs_add_device(dev);
+}
similarity index 82%
rename from direct/basic-test/yaffs_norif1.h
rename to direct/basic-test/yaffs_m18_drv.h
index d245b6d..7befb1a 100644 (file)
  */
 
 
-#ifndef __YAFFS_NOR_IF1_H__
-#define __YAFFS_NOR_IF1_H__
+#ifndef __YAFFS_M18_DRV_H__
+#define __YAFFS_M18_DRV_H__
 
 struct yaffs_dev;
-void ynorif1_install_drv(struct yaffs_dev *dev);
+struct yaffs_dev *yaffs_m18_install_drv(const char *name);
 
 #endif
 
index 4849889..deafabd 100644 (file)
@@ -23,7 +23,6 @@
 #include "yaffsfs.h"
 #include "yaffs_fileem2k.h"
 #include "yaffs_nandemul2k.h"
-#include "yaffs_norif1.h"
 #include "yaffs_trace.h"
 #include "yaffs_osglue.h"
 
@@ -47,10 +46,8 @@ unsigned yaffs_trace_mask =
 
 // Configuration
 
-#include "yaffs_ramdisk.h"
-#include "yaffs_flashif.h"
 #include "yaffs_flashif2.h"
-#include "yaffs_nandemul2k.h"
+#include "yaffs_m18_drv.h"
 
 struct yaffs_dev ram1Dev;
 struct yaffs_dev flashDev;
@@ -68,37 +65,11 @@ int yaffs_start_up(void)
        // Stuff to initialise anything special (eg lock semaphore).
        yaffsfs_OSInitialisation();
 
-       // Set up devices
-
-       // /M18-1 yaffs1 on M18 nor sim
-       memset(&m18_1Dev,0,sizeof(m18_1Dev));
-       ynorif1_install_drv(&m18_1Dev);
-       m18_1Dev.param.name = "M18-1";
-       m18_1Dev.param.n_caches = 10; // Use caches
-       m18_1Dev.param.disable_soft_del = 1;
-       m18_1Dev.driver_context = (void *) 1;   // Used to identify the device in fstat.
-
-
-//     m18_1Dev.param.disable_soft_del = 1;
 
-       yaffs_add_device(&m18_1Dev);
+       yaffs_m18_install_drv("M18-1");
 
        // /yaffs2  yaffs2 file emulation
-       // 2kpage/64chunk per block
-       //
-       memset(&flashDev,0,sizeof(flashDev));
-       yflash2_install_drv(&flashDev);
-       flashDev.param.name = "yaffs2";
-
-       flashDev.param.n_reserved_blocks = 5;
-       flashDev.param.wide_tnodes_disabled=0;
-       flashDev.param.refresh_period = 1000;
-       flashDev.param.n_caches = 10; // Use caches
-       flashDev.driver_context = (void *) 2;   // Used to identify the device in fstat.
-
-       flashDev.param.enable_xattr = 1;
-
-       yaffs_add_device(&flashDev);
+       yflash2_install_drv("yaffs2");
 
        return 0;
 }
index 4229196..e739fb4 100644 (file)
@@ -159,7 +159,7 @@ static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
                        enum yaffs_block_state state;
                        u32 seq;
 
-                       dev->th.read_chunk_tags_fn(dev,
+                       dev->tagger.read_chunk_tags_fn(dev,
                                        apply_chunk_offset(dev, chunk),
                                        NULL, &tags);
                        yaffs_trace(YAFFS_TRACE_CHECKPOINT,
@@ -171,7 +171,7 @@ static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
                        if (tags.seq_number != YAFFS_SEQUENCE_CHECKPOINT_DATA)
                                continue;
 
-                       dev->th.query_block_fn(dev,
+                       dev->tagger.query_block_fn(dev,
                                                apply_block_offset(dev, i),
                                                &state, &seq);
                        if (state == YAFFS_BLOCK_STATE_DEAD)
@@ -200,8 +200,8 @@ int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing)
        dev->checkpt_open_write = writing;
 
        /* Got the functions we need? */
-       if (!dev->th.write_chunk_tags_fn ||
-           !dev->th.read_chunk_tags_fn ||
+       if (!dev->tagger.write_chunk_tags_fn ||
+           !dev->tagger.read_chunk_tags_fn ||
            !dev->drv.drv_erase_fn ||
            !dev->drv.drv_mark_bad_fn)
                return 0;
@@ -299,7 +299,7 @@ static int yaffs2_checkpt_flush_buffer(struct yaffs_dev *dev)
 
        dev->n_page_writes++;
 
-       dev->th.write_chunk_tags_fn(dev, offset_chunk,
+       dev->tagger.write_chunk_tags_fn(dev, offset_chunk,
                                       dev->checkpt_buffer, &tags);
        dev->checkpt_page_seq++;
        dev->checkpt_cur_chunk++;
@@ -383,7 +383,7 @@ int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes)
                        dev->n_page_reads++;
 
                        /* read in the next chunk */
-                       dev->th.read_chunk_tags_fn(dev,
+                       dev->tagger.read_chunk_tags_fn(dev,
                                                offset_chunk,
                                                dev->checkpt_buffer,
                                                &tags);
index ce5f238..3c1aa10 100644 (file)
@@ -609,7 +609,7 @@ static void yaffs_retire_block(struct yaffs_dev *dev, int flash_block)
                        memset(buffer, 0xff, dev->data_bytes_per_chunk);
                        memset(&tags, 0, sizeof(tags));
                        tags.seq_number = YAFFS_SEQUENCE_BAD_BLOCK;
-                       if (dev->th.write_chunk_tags_fn(dev, chunk_id -
+                       if (dev->tagger.write_chunk_tags_fn(dev, chunk_id -
                                                        dev->chunk_offset,
                                                        buffer,
                                                        &tags) != YAFFS_OK)
@@ -4536,7 +4536,7 @@ YCHAR *yaffs_get_symlink_alias(struct yaffs_obj *obj)
 static int yaffs_check_dev_fns(struct yaffs_dev *dev)
 {
        struct yaffs_driver *drv = &dev->drv;
-       struct yaffs_tags_handler *th = &dev->th;
+       struct yaffs_tags_handler *tagger = &dev->tagger;
 
        /* Common functions, gotta have */
        if (!drv->drv_read_chunk_fn ||
@@ -4553,10 +4553,10 @@ static int yaffs_check_dev_fns(struct yaffs_dev *dev)
        yaffs_tags_marshall_install(dev);
 
        /* Check we now have the marshalling functions required. */
-       if (!th->write_chunk_tags_fn ||
-           !th->read_chunk_tags_fn ||
-           !th->query_block_fn ||
-           !th->mark_bad_fn)
+       if (!tagger->write_chunk_tags_fn ||
+           !tagger->read_chunk_tags_fn ||
+           !tagger->query_block_fn ||
+           !tagger->mark_bad_fn)
                return 0;
 
        return 1;
index f108f21..62d18cb 100644 (file)
@@ -627,7 +627,7 @@ struct yaffs_tags_handler {
 struct yaffs_dev {
        struct yaffs_param param;
        struct yaffs_driver drv;
-       struct yaffs_tags_handler th;
+       struct yaffs_tags_handler tagger;
 
        /* Context storage. Holds extra OS specific data for this device */
 
index d322e35..9afd5ec 100644 (file)
@@ -35,7 +35,7 @@ int yaffs_rd_chunk_tags_nand(struct yaffs_dev *dev, int nand_chunk,
        if (!tags)
                tags = &local_tags;
 
-       result = dev->th.read_chunk_tags_fn(dev, flash_chunk, buffer, tags);
+       result = dev->tagger.read_chunk_tags_fn(dev, flash_chunk, buffer, tags);
        if (tags && tags->ecc_result > YAFFS_ECC_RESULT_NO_ERROR) {
 
                struct yaffs_block_info *bi;
@@ -68,7 +68,7 @@ int yaffs_wr_chunk_tags_nand(struct yaffs_dev *dev,
                "Writing chunk %d tags %d %d",
                nand_chunk, tags->obj_id, tags->chunk_id);
 
-       result = dev->th.write_chunk_tags_fn(dev, flash_chunk,
+       result = dev->tagger.write_chunk_tags_fn(dev, flash_chunk,
                                                        buffer, tags);
 
        yaffs_summary_add(dev, tags, nand_chunk);
@@ -80,7 +80,7 @@ int yaffs_mark_bad(struct yaffs_dev *dev, int block_no)
 {
        block_no -= dev->block_offset;
        dev->n_bad_markings++;
-       return dev->th.mark_bad_fn(dev, block_no);
+       return dev->tagger.mark_bad_fn(dev, block_no);
 }
 
 
@@ -90,7 +90,7 @@ int yaffs_query_init_block_state(struct yaffs_dev *dev,
                                 u32 *seq_number)
 {
        block_no -= dev->block_offset;
-       return dev->th.query_block_fn(dev, block_no, state, seq_number);
+       return dev->tagger.query_block_fn(dev, block_no, state, seq_number);
 }
 
 int yaffs_erase_block(struct yaffs_dev *dev, int block_no)
index e213a31..092430b 100644 (file)
@@ -350,6 +350,7 @@ static int yaffs_tags_compat_query_block(struct yaffs_dev *dev,
 
        *seq_number = 0;
 
+       /* Look for bad block markers in the first two chunks */
        yaffs_rd_chunk_nand(dev, block_no * dev->param.chunks_per_block,
                            NULL, &spare0, &dummy, 0);
        yaffs_rd_chunk_nand(dev, block_no * dev->param.chunks_per_block + 1,
@@ -369,12 +370,12 @@ void yaffs_tags_compat_install(struct yaffs_dev *dev)
 {
        if(dev->param.is_yaffs2)
                return;
-       if(!dev->th.write_chunk_tags_fn)
-               dev->th.write_chunk_tags_fn = yaffs_tags_compat_wr;
-       if(!dev->th.read_chunk_tags_fn)
-               dev->th.read_chunk_tags_fn = yaffs_tags_compat_rd;
-       if(!dev->th.query_block_fn)
-               dev->th.query_block_fn = yaffs_tags_compat_query_block;
-       if(!dev->th.mark_bad_fn)
-               dev->th.mark_bad_fn = yaffs_tags_compat_mark_bad;
+       if(!dev->tagger.write_chunk_tags_fn)
+               dev->tagger.write_chunk_tags_fn = yaffs_tags_compat_wr;
+       if(!dev->tagger.read_chunk_tags_fn)
+               dev->tagger.read_chunk_tags_fn = yaffs_tags_compat_rd;
+       if(!dev->tagger.query_block_fn)
+               dev->tagger.query_block_fn = yaffs_tags_compat_query_block;
+       if(!dev->tagger.mark_bad_fn)
+               dev->tagger.mark_bad_fn = yaffs_tags_compat_mark_bad;
 }
index 401a756..44a83b1 100644 (file)
@@ -184,16 +184,16 @@ void yaffs_tags_marshall_install(struct yaffs_dev *dev)
        if (!dev->param.is_yaffs2)
                return;
 
-       if (!dev->th.write_chunk_tags_fn)
-               dev->th.write_chunk_tags_fn = yaffs_tags_marshall_write;
+       if (!dev->tagger.write_chunk_tags_fn)
+               dev->tagger.write_chunk_tags_fn = yaffs_tags_marshall_write;
 
-       if (!dev->th.read_chunk_tags_fn)
-               dev->th.read_chunk_tags_fn = yaffs_tags_marshall_read;
+       if (!dev->tagger.read_chunk_tags_fn)
+               dev->tagger.read_chunk_tags_fn = yaffs_tags_marshall_read;
 
-       if (!dev->th.query_block_fn)
-               dev->th.query_block_fn = yaffs_tags_marshall_query_block;
+       if (!dev->tagger.query_block_fn)
+               dev->tagger.query_block_fn = yaffs_tags_marshall_query_block;
 
-       if (!dev->th.mark_bad_fn)
-               dev->th.mark_bad_fn = yaffs_tags_marshall_mark_bad;
+       if (!dev->tagger.mark_bad_fn)
+               dev->tagger.mark_bad_fn = yaffs_tags_marshall_mark_bad;
 
 }