Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
authorCharles Manning <cdhmanning@gmail.com>
Wed, 3 Nov 2010 03:21:38 +0000 (16:21 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Wed, 3 Nov 2010 03:21:38 +0000 (16:21 +1300)
86 files changed:
Makefile
Makefile.kernel
devextras.h [deleted file]
direct/basic-test/Makefile
direct/basic-test/dtest.c
direct/basic-test/yaffs_fileem.c
direct/basic-test/yaffs_fileem2k.c
direct/basic-test/yaffs_norif1.c
direct/basic-test/yaffs_norif1.h
direct/basic-test/yaffs_ramdisk.c
direct/basic-test/yaffs_ramdisk.h
direct/basic-test/yaffs_ramem2k.c
direct/basic-test/yaffscfg.c
direct/basic-test/yaffscfg2k.c
direct/basic-test/yaffsnewcfg.c
direct/basic-test/ynorsim.c
direct/basic-test/ynorsim.h
direct/basic-test/yramsim.c
direct/basic-test/yramsim.h
direct/python/Makefile
direct/tests/Makefile
direct/yaffs_attribs.c [new file with mode: 0644]
direct/yaffs_flashif.c
direct/yaffs_flashif.h
direct/yaffs_flashif2.h
direct/yaffs_list.h [moved from yaffs_list.h with 64% similarity]
direct/yaffs_nandemul2k.h
direct/yaffs_nandif.c
direct/yaffs_nandif.h
direct/yaffscfg.h
direct/yaffsfs.c
direct/yaffsfs.h
direct/ydirectenv.h
direct/yportenv.h [new file with mode: 0644]
moduleconfig.h
mtdemul/nandemul2k.c
patch-ker.sh
patches/yaffs_linux_allocator.c [moved from yaffs_linux_allocator.c with 90% similarity]
patches/yaffs_mtdif2.c
utils/mkyaffs2image.c
utils/mkyaffsimage.c
yaffs_allocator.c
yaffs_allocator.h
yaffs_attribs.c [new file with mode: 0644]
yaffs_attribs.h [moved from yaffs_qsort.h with 50% similarity]
yaffs_bitmap.c
yaffs_bitmap.h
yaffs_checkptrw.c
yaffs_checkptrw.h
yaffs_ecc.c
yaffs_ecc.h
yaffs_getblockinfo.h
yaffs_guts.c
yaffs_guts.h
yaffs_linux.h
yaffs_mtdif.c
yaffs_mtdif.h
yaffs_mtdif1.h
yaffs_mtdif1_multi.c [moved from yaffs_mtdif1.c with 81% similarity]
yaffs_mtdif1_single.c [new file with mode: 0644]
yaffs_mtdif2.h
yaffs_mtdif2_multi.c [moved from yaffs_mtdif2.c with 69% similarity]
yaffs_mtdif2_single.c [new file with mode: 0644]
yaffs_nameval.c
yaffs_nameval.h
yaffs_nand.c
yaffs_nand.h
yaffs_packedtags1.c
yaffs_packedtags1.h
yaffs_packedtags2.c
yaffs_packedtags2.h
yaffs_tagscompat.c
yaffs_tagscompat.h
yaffs_tagsvalidity.c
yaffs_tagsvalidity.h
yaffs_trace.h
yaffs_verify.c
yaffs_verify.h
yaffs_vfs_multi.c
yaffs_vfs_single.c [moved from yaffs_vfs.c with 66% similarity]
yaffs_yaffs1.c
yaffs_yaffs1.h
yaffs_yaffs2.c
yaffs_yaffs2.h
yportenv_multi.h [moved from yportenv.h with 95% similarity]
yportenv_single.h [new file with mode: 0644]

index a6b5d14..1dbafc6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,26 +26,26 @@ ifneq ($(KERNELRELEASE),)
 
        obj-m := $(YAFFS_O)
 
-       yaffs2-objs := yaffs_mtdif.o yaffs_mtdif2.o
-       yaffs2-objs += yaffs_mtdif1.o yaffs_packedtags1.o
-       yaffs2-objs += yaffs_ecc.o yaffs_vfs.o yaffs_guts.o
+       yaffs2-objs := yaffs_mtdif.o yaffs_mtdif2_single.o
+       yaffs2-objs += yaffs_mtdif1_single.o yaffs_packedtags1.o
+       yaffs2-objs += yaffs_ecc.o yaffs_vfs_single.o yaffs_guts.o
        yaffs2-objs += yaffs_packedtags2.o
        yaffs2-objs += yaffs_tagscompat.o yaffs_tagsvalidity.o
        yaffs2-objs += yaffs_checkptrw.o yaffs_nand.o
        yaffs2-objs += yaffs_checkptrw.o yaffs_nand.o yaffs_nameval.o
-       yaffs2-objs += yaffs_allocator.o yaffs_bitmap.o
+       yaffs2-objs += yaffs_allocator.o yaffs_bitmap.o yaffs_attribs.o
        yaffs2-objs += yaffs_yaffs1.o
        yaffs2-objs += yaffs_yaffs2.o
        yaffs2-objs += yaffs_verify.o
 
-       yaffs2multi-objs := yaffs_mtdif.o yaffs_mtdif2.o
-       yaffs2multi-objs += yaffs_mtdif1.o yaffs_packedtags1.o
+       yaffs2multi-objs := yaffs_mtdif.o yaffs_mtdif2_multi.o
+       yaffs2multi-objs += yaffs_mtdif1_multi.o yaffs_packedtags1.o
        yaffs2multi-objs += yaffs_ecc.o yaffs_vfs_multi.o yaffs_guts.o
        yaffs2multi-objs += yaffs_packedtags2.o
        yaffs2multi-objs += yaffs_tagscompat.o yaffs_tagsvalidity.o
        yaffs2multi-objs += yaffs_checkptrw.o yaffs_nand.o
        yaffs2multi-objs += yaffs_checkptrw.o yaffs_nand.o yaffs_nameval.o
-       yaffs2multi-objs += yaffs_allocator.o yaffs_bitmap.o
+       yaffs2multi-objs += yaffs_allocator.o yaffs_bitmap.o yaffs_attribs.o
        yaffs2multi-objs += yaffs_yaffs1.o
        yaffs2multi-objs += yaffs_yaffs2.o
        yaffs2multi-objs += yaffs_verify.o
index fbdbd4a..e63a28a 100644 (file)
@@ -4,11 +4,11 @@
 
 obj-$(CONFIG_YAFFS_FS) += yaffs.o
 
-yaffs-y := yaffs_ecc.o yaffs_vfs_glue.o yaffs_guts.o yaffs_checkptrw.o
+yaffs-y := yaffs_ecc.o yaffs_vfs.o yaffs_guts.o yaffs_checkptrw.o
 yaffs-y += yaffs_packedtags1.o yaffs_packedtags2.o yaffs_nand.o
 yaffs-y += yaffs_tagscompat.o yaffs_tagsvalidity.o
 yaffs-y += yaffs_mtdif.o yaffs_mtdif1.o yaffs_mtdif2.o
-yaffs-y += yaffs_nameval.o
+yaffs-y += yaffs_nameval.o yaffs_attribs.o
 yaffs-y += yaffs_allocator.o
 yaffs-y += yaffs_yaffs1.o
 yaffs-y += yaffs_yaffs2.o
diff --git a/devextras.h b/devextras.h
deleted file mode 100644 (file)
index ce30c82..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
- *
- * Copyright (C) 2002-2010 Aleph One Ltd.
- *   for Toby Churchill Ltd and Brightstar Engineering
- *
- * Created by Charles Manning <charles@aleph1.co.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 2.1 as
- * published by the Free Software Foundation.
- *
- * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
- */
-
-/*
- * This file is just holds extra declarations of macros that would normally
- * be providesd in the Linux kernel. These macros have been written from
- * scratch but are functionally equivalent to the Linux ones.
- *
- */
-
-#ifndef __EXTRAS_H__
-#define __EXTRAS_H__
-
-
-#include "yportenv.h"
-
-#if !(defined __KERNEL__)
-
-/* Definition of types */
-typedef unsigned char __u8;
-typedef unsigned short __u16;
-typedef unsigned __u32;
-
-#endif
-
-
-#if !(defined __KERNEL__)
-
-
-#ifndef WIN32
-#include <sys/stat.h>
-#endif
-
-
-#ifdef CONFIG_YAFFS_PROVIDE_DEFS
-/* File types */
-
-
-#define DT_UNKNOWN     0
-#define DT_FIFO                1
-#define DT_CHR         2
-#define DT_DIR         4
-#define DT_BLK         6
-#define DT_REG         8
-#define DT_LNK         10
-#define DT_SOCK                12
-#define DT_WHT         14
-
-
-#ifndef WIN32
-#include <sys/stat.h>
-#endif
-
-/*
- * Attribute flags.  These should be or-ed together to figure out what
- * has been changed!
- */
-#define ATTR_MODE      1
-#define ATTR_UID       2
-#define ATTR_GID       4
-#define ATTR_SIZE      8
-#define ATTR_ATIME     16
-#define ATTR_MTIME     32
-#define ATTR_CTIME     64
-
-struct iattr {
-       unsigned int ia_valid;
-       unsigned ia_mode;
-       unsigned ia_uid;
-       unsigned ia_gid;
-       unsigned ia_size;
-       unsigned ia_atime;
-       unsigned ia_mtime;
-       unsigned ia_ctime;
-       unsigned int ia_attr_flags;
-};
-
-#endif
-
-#else
-
-#include <linux/types.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-
-#endif
-
-
-#endif
index 4054ed1..7847528 100644 (file)
@@ -34,8 +34,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf
                 yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
                 yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
                 yaffs_checkptrw.o  yaffs_qsort.o\
-                yaffs_nameval.o \
-                yaffs_norif1.o  ynorsim.o nor_stress.o yaffs_fsx.o \
+                yaffs_nameval.o yaffs_attribs.o \
+                yaffs_norif1.o  ynorsim.o \
                 yaffs_allocator.o \
                 yaffs_bitmap.o \
                 yaffs_yaffs1.o \
@@ -44,17 +44,13 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf
 
 #               yaffs_checkptrwtest.o\
 
-YAFFSTESTOBJS  = $(COMMONTESTOBJS) yaffs_test.o
-
 
-ALLOBJS = $(sort $(YAFFSTESTOBJS))
-
-YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
           yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \
-          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h yaffs_list.h \
+          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
           yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
           yaffs_nameval.c yaffs_nameval.h \
-          yaffs_qsort.h yaffs_trace.h \
+          yaffs_trace.h yaffs_attribs.h \
           yaffs_allocator.c yaffs_allocator.h \
           yaffs_yaffs1.c yaffs_yaffs1.h \
           yaffs_yaffs2.c yaffs_yaffs2.h \
@@ -63,8 +59,8 @@ YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yp
 
 YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
                       yaffsfs.h yaffs_malloc.h ydirectenv.h \
-                      yaffs_flashif.c yaffscfg.h \
-                      yaffs_qsort.c \
+                      yaffs_flashif.c yaffscfg.h yaffs_list.h \
+                      yaffs_qsort.c yportenv.h yaffs_attribs.c \
                       yaffs_nandif.c yaffs_nandif.h yaffs_nandemul2k.h
 
 
@@ -72,21 +68,6 @@ YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
 SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS)
 
 
-
-
-COMMONTESTOBJS = yaffsnewcfg.o  yramsim.o \
-                yaffsfs.o yaffs_guts.o yaffs_ecc.o yaffs_nandif.o \
-                yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
-                yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
-                yaffs_checkptrw.o  yaffs_qsort.o\
-                yaffs_nameval.o \
-                yaffs_norif1.o  ynorsim.o \
-                yaffs_allocator.o yaffs_yaffs1.o \
-                yaffs_yaffs2.o \
-                yaffs_bitmap.o yaffs_verify.o
-
-#               yaffs_checkptrwtest.o\
-
 DIRECTTESTOBJS = $(COMMONTESTOBJS) dtest.o
 
 BOOTTESTOBJS = bootldtst.o yboot.o yaffs_fileem.o nand_ecc.o
index 691ffe2..e6a0a14 100644 (file)
@@ -2516,7 +2516,7 @@ static void print_xattrib_val(const char *path, const char *name)
 
        n = yaffs_getxattr(path,name,buffer,sizeof(buffer));
        if(n >= 0){
-               __u8 *b = (__u8 *)buffer;
+               u8 *b = (u8 *)buffer;
 
                printf("%d bytes:",n);
                if(n > 10)
@@ -2642,7 +2642,7 @@ void big_xattr_test(const char *mountpt)
 }
 
 
-void dump_dev_stats(yaffs_dev_t *dev, const char * str)
+void dump_dev_stats(struct yaffs_dev *dev, const char * str)
 {
        printf("%s\n",str);
        printf( "space free %d erased %d "
@@ -2658,7 +2658,7 @@ void test_flash_traffic(const char *mountpt)
        char name0[100];
        char name1[100];
        int i;
-       yaffs_dev_t *dev;
+       struct yaffs_dev *dev;
 
        yaffs_trace_mask = 0;
 
index 419b16f..702acbe 100644 (file)
@@ -25,8 +25,6 @@ const char *yaffs_flashif_c_version = "$Id: yaffs_fileem.c,v 1.7 2010-02-18 01:1
 #include "yaffs_flashif.h"
 #include "yaffs_guts.h"
 
-#include "devextras.h"
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -43,7 +41,7 @@ const char *yaffs_flashif_c_version = "$Id: yaffs_fileem.c,v 1.7 2010-02-18 01:1
 
 typedef struct 
 {
-       __u8 data[528]; // Data + spare
+       u8 data[528]; // Data + spare
 } yflash_Page;
 
 typedef struct
@@ -62,7 +60,7 @@ typedef struct
 
 static yflash_Device filedisk;
 
-static int  CheckInit(yaffs_dev_t *dev)
+static int  CheckInit(struct yaffs_dev *dev)
 {
        static int initialised = 0;
        
@@ -118,7 +116,7 @@ static int  CheckInit(yaffs_dev_t *dev)
        return 1;
 }
 
-int yflash_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_spare *spare)
+int yflash_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_spare *spare)
 {
        int written;
 
@@ -148,7 +146,7 @@ int yflash_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, co
 }
 
 
-int yflash_ReadChunkFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_spare *spare)
+int yflash_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_spare *spare)
 {
        int nread;
 
@@ -178,7 +176,7 @@ int yflash_ReadChunkFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_
 }
 
 
-int yflash_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
+int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
 
        int i;
@@ -208,7 +206,7 @@ int yflash_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
        
 }
 
-int yflash_InitialiseNAND(yaffs_dev_t *dev)
+int yflash_InitialiseNAND(struct yaffs_dev *dev)
 {
        
        return YAFFS_OK;
index 367003e..06e41e5 100644 (file)
@@ -24,23 +24,23 @@ const char *yaffs_flashif2_c_version = "$Id: yaffs_fileem2k.c,v 1.24 2010-02-18
 
 #include "yaffs_flashif2.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
+#include "yaffs_fileem2k.h"
+#include "yaffs_packedtags2.h"
+#include "yaffs_tagsvalidity.h"
+
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h> 
 
-#include "yaffs_fileem2k.h"
-#include "yaffs_packedtags2.h"
-
 
 
 #define REPORT_ERROR 0
 
 typedef struct 
 {
-       __u8 data[PAGE_SIZE]; // Data + spare
+       u8 data[PAGE_SIZE]; // Data + spare
 } yflash_Page;
 
 typedef struct
@@ -66,7 +66,6 @@ int yaffs_test_partial_write = 0;
 
 extern int random_seed;
 extern int simulate_power_failure;
-static int initialised = 0;
 static int remaining_ops;
 static int nops_so_far;
 
@@ -93,7 +92,7 @@ static void yflash2_MaybePowerFail(unsigned int nand_chunk, int failPoint)
 
 
 
-static __u8 localBuffer[PAGE_SIZE];
+static u8 localBuffer[PAGE_SIZE];
 
 static char *NToName(char *buf,int n)
 {
@@ -171,7 +170,7 @@ int yflash2_GetNumberOfBlocks(void)
        return filedisk.nBlocks;
 }
 
-int yflash2_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_ext_tags *tags)
+int yflash2_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_ext_tags *tags)
 {
        int written;
        int pos;
@@ -180,15 +179,15 @@ int yflash2_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8
        int nRead;
        int error;
        
-       T(YAFFS_TRACE_MTD,(TSTR("write chunk %d data %x tags %x" TENDSTR),nand_chunk,(unsigned)data, (unsigned)tags));
+       T(YAFFS_TRACE_MTD,(TSTR("write chunk %d data %p tags %p" TENDSTR),nand_chunk, data, tags));
 
        CheckInit();
        
        
        if(dev->param.inband_tags){
                
-               yaffs_packed_tags2_tags_only * pt2tp;
-               pt2tp = (yaffs_packed_tags2_tags_only *)&data[dev->data_bytes_per_chunk];
+               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);
                
                pos = (nand_chunk % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE;
@@ -255,14 +254,14 @@ int yflash2_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8
                        if( 0 && dev->param.is_yaffs2)
                        {
                        
-                               written = write(h,tags,sizeof(yaffs_ext_tags));
-                               if(written != sizeof(yaffs_ext_tags)) return YAFFS_FAIL;
+                               written = write(h,tags,sizeof(struct yaffs_ext_tags));
+                               if(written != sizeof(struct yaffs_ext_tags)) return YAFFS_FAIL;
                        }
                        else
                        {
-                               yaffs_packed_tags2 pt;
+                               struct yaffs_packed_tags2 pt;
                                yaffs_pack_tags2(&pt,tags, !dev->param.no_tags_ecc);
-                               __u8 * ptab = (__u8 *)&pt;
+                               u8 * ptab = (u8 *)&pt;
 
                                nRead = read(h,localBuffer,sizeof(pt));
                                for(i = error = 0; REPORT_ERROR && i < sizeof(pt) && !error; i++){
@@ -333,14 +332,14 @@ int yflash2_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8
                        if( 0 && dev->param.is_yaffs2)
                        {
                        
-                               written = write(h,tags,sizeof(yaffs_ext_tags));
-                               if(written != sizeof(yaffs_ext_tags)) return YAFFS_FAIL;
+                               written = write(h,tags,sizeof(struct yaffs_ext_tags));
+                               if(written != sizeof(struct yaffs_ext_tags)) return YAFFS_FAIL;
                        }
                        else
                        {
-                               yaffs_packed_tags2 pt;
+                               struct yaffs_packed_tags2 pt;
                                yaffs_pack_tags2(&pt,tags,!dev->param.no_tags_ecc);
-                               __u8 * ptab = (__u8 *)&pt;
+                               u8 * ptab = (u8 *)&pt;
 
                                nRead = read(h,localBuffer,sizeof(pt));
                                for(i = error = 0; REPORT_ERROR && i < sizeof(pt) && !error; i++){
@@ -371,7 +370,7 @@ int yflash2_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8
 
 }
 
-int yaffs_check_all_ff(const __u8 *ptr, int n)
+int yaffs_check_all_ff(const u8 *ptr, int n)
 {
        while(n)
        {
@@ -388,7 +387,7 @@ static int fail320 = 1;
 
 static int failRead10 = 2;
 
-int yflash2_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tags *tags)
+int yflash2_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_ext_tags *tags)
 {
        int nread;
        int pos;
@@ -397,7 +396,7 @@ int yflash2_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *dat
        int retval = YAFFS_OK;
        int nRead;
        
-       T(YAFFS_TRACE_MTD,(TSTR("read chunk %d data %x tags %x" TENDSTR),nand_chunk,(unsigned)data, (unsigned)tags));
+       T(YAFFS_TRACE_MTD,(TSTR("read chunk %d data %p tags %p" TENDSTR),nand_chunk, data, tags));
        
        CheckInit();
        
@@ -412,8 +411,8 @@ int yflash2_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *dat
                }
 
                
-               yaffs_packed_tags2_tags_only * pt2tp;
-               pt2tp = (yaffs_packed_tags2_tags_only *)&data[dev->data_bytes_per_chunk];
+               struct yaffs_packed_tags2_tags_only * pt2tp;
+               pt2tp = (struct yaffs_packed_tags2_tags_only *)&data[dev->data_bytes_per_chunk];
 
                
                pos = (nand_chunk % (PAGES_PER_BLOCK * BLOCKS_PER_HANDLE)) * PAGE_SIZE;
@@ -458,10 +457,10 @@ int yflash2_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *dat
 
                        if(0 && dev->param.is_yaffs2)
                        {
-                               nread= read(h,tags,sizeof(yaffs_ext_tags));
-                               if(nread != sizeof(yaffs_ext_tags))
+                               nread= read(h,tags,sizeof(struct yaffs_ext_tags));
+                               if(nread != sizeof(struct yaffs_ext_tags))
                                         retval =  YAFFS_FAIL;
-                               if(yaffs_check_all_ff((__u8 *)tags,sizeof(yaffs_ext_tags)))
+                               if(yaffs_check_all_ff((u8 *)tags,sizeof(struct yaffs_ext_tags)))
                                {
                                        yaffs_init_tags(tags);
                                }
@@ -472,7 +471,7 @@ int yflash2_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *dat
                        }
                        else
                        {
-                               yaffs_packed_tags2 pt;
+                               struct yaffs_packed_tags2 pt;
                                nread= read(h,&pt,sizeof(pt));
                                yaffs_unpack_tags2(tags,&pt, !dev->param.no_tags_ecc);
 #ifdef SIMULATE_FAILURES
@@ -508,12 +507,12 @@ int yflash2_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *dat
 }
 
 
-int yflash2_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no)
+int yflash2_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no)
 {
        int written;
        int h;
        
-       yaffs_packed_tags2 pt;
+       struct yaffs_packed_tags2 pt;
 
        CheckInit();
        
@@ -529,7 +528,7 @@ int yflash2_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no)
        
 }
 
-int yflash2_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
+int yflash2_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
 
        int i;
@@ -550,7 +549,7 @@ int yflash2_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
        else
        {
        
-               __u8 pg[PAGE_SIZE];
+               u8 pg[PAGE_SIZE];
                int syz = PAGE_SIZE;
                int pos;
                
@@ -570,7 +569,7 @@ int yflash2_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
        
 }
 
-int yflash2_InitialiseNAND(yaffs_dev_t *dev)
+int yflash2_InitialiseNAND(struct yaffs_dev *dev)
 {
        CheckInit();
        
@@ -580,9 +579,9 @@ int yflash2_InitialiseNAND(yaffs_dev_t *dev)
 
 
 
-int yflash2_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no, yaffs_block_state_t *state, __u32 *seq_number)
+int yflash2_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, u32 *seq_number)
 {
-       yaffs_ext_tags tags;
+       struct yaffs_ext_tags tags;
        int chunkNo;
 
        *seq_number = 0;
index 5657c00..7be6295 100644 (file)
@@ -45,8 +45,6 @@ const char *yaffs_norif1_c_version = "$Id: yaffs_norif1.c,v 1.6 2010-02-18 01:18
 #include "yaffs_flashif.h"
 #include "yaffs_guts.h"
 
-#include "devextras.h"
-
 #define SPARE_BYTES_PER_CHUNK  16
 #define M18_SKIP               16
 #define PROG_REGION_SIZE       1024
@@ -88,58 +86,58 @@ const char *yaffs_norif1_c_version = "$Id: yaffs_norif1.c,v 1.6 2010-02-18 01:18
 #define DEVICE_BASE     (32 * 1024 * 1024)
 #endif
 
-__u32 *Block2Addr(yaffs_dev_t *dev, int blockNumber)
+u32 *Block2Addr(struct yaffs_dev *dev, int blockNumber)
 {
-       __u32 addr;
+       u32 addr;
        dev=dev;
        
-       addr = (__u32) DEVICE_BASE;
+       addr = (u32) DEVICE_BASE;
        addr += blockNumber * BLOCK_SIZE_IN_BYTES;
        
-       return (__u32 *) addr;
+       return (u32 *) addr;
 }
 
-__u32 *Block2FormatAddr(yaffs_dev_t *dev,int blockNumber)
+u32 *Block2FormatAddr(struct yaffs_dev *dev,int blockNumber)
 {
-       __u32 addr;
+       u32 addr;
 
-       addr = (__u32) Block2Addr(dev,blockNumber);
+       addr = (u32) Block2Addr(dev,blockNumber);
        addr += FORMAT_OFFSET;
        
-       return (__u32 *)addr;
+       return (u32 *)addr;
 }
-__u32 *Chunk2DataAddr(yaffs_dev_t *dev,int chunk_id)
+u32 *Chunk2DataAddr(struct yaffs_dev *dev,int chunk_id)
 {
        unsigned block;
        unsigned chunkInBlock;
-       __u32  addr;
+       u32  addr;
        
        block = chunk_id/dev->param.chunks_per_block;
        chunkInBlock = chunk_id % dev->param.chunks_per_block;
        
-       addr = (__u32) Block2Addr(dev,block);
+       addr = (u32) Block2Addr(dev,block);
        addr += chunkInBlock * DATA_BYTES_PER_CHUNK;
        
-       return (__u32 *)addr;
+       return (u32 *)addr;
 }
 
-__u32 *Chunk2SpareAddr(yaffs_dev_t *dev,int chunk_id)
+u32 *Chunk2SpareAddr(struct yaffs_dev *dev,int chunk_id)
 {
        unsigned block;
        unsigned chunkInBlock;
-       __u32 addr;
+       u32 addr;
        
        block = chunk_id/dev->param.chunks_per_block;
        chunkInBlock = chunk_id % dev->param.chunks_per_block;
        
-       addr = (__u32) Block2Addr(dev,block);
+       addr = (u32) Block2Addr(dev,block);
        addr += SPARE_AREA_OFFSET;
        addr += chunkInBlock * (SPARE_BYTES_PER_CHUNK + M18_SKIP);
-       return (__u32 *)addr;
+       return (u32 *)addr;
 }
 
 
-void ynorif1_AndBytes(__u8*target, const __u8   *src, int nbytes)
+void ynorif1_AndBytes(u8*target, const u8   *src, int nbytes)
 {
         while(nbytes > 0){
                 *target &= *src;
@@ -149,12 +147,12 @@ void ynorif1_AndBytes(__u8*target, const __u8   *src, int nbytes)
         }
 }
 
-int ynorif1_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_spare *spare)
+int ynorif1_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_spare *spare)
 {
-        __u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
-        __u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
+        u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
+        u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
         
-        yaffs_spare tmpSpare;
+        struct yaffs_spare tmpSpare;
         
         /* We should only be getting called for one of 3 reasons:
          * Writing a chunk: data and spare will not be NULL
@@ -162,7 +160,7 @@ int ynorif1_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, c
          * Writing a bad block marker: data will be NULL, spare not NULL
          */
          
-        if(sizeof(yaffs_spare) != 16)
+        if(sizeof(struct yaffs_spare) != 16)
                 YBUG();
         
         if(data && spare)
@@ -172,30 +170,30 @@ int ynorif1_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, c
                 /* Write a pre-marker */
                 memset(&tmpSpare,0xff,sizeof(tmpSpare));
                 tmpSpare.page_status = YNOR_PREMARKER;
-                ynorif1_FlashWrite32(spareAddr,(__u32 *)&tmpSpare,sizeof(yaffs_spare)/4);
+                ynorif1_FlashWrite32(spareAddr,(u32 *)&tmpSpare,sizeof(struct yaffs_spare)/4);
 
                 /* Write the data */            
-                ynorif1_FlashWrite32(dataAddr,(__u32 *)data,dev->param.total_bytes_per_chunk / 4);
+                ynorif1_FlashWrite32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / 4);
                 
                 
-                memcpy(&tmpSpare,spare,sizeof(yaffs_spare));
+                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(yaffs_spare)/4);
+                ynorif1_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);  
+                ynorif1_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);
+                ynorif1_FlashRead32(spareAddr,(u32 *)&tmpSpare,16/ 4);
                 
-                ynorif1_AndBytes((__u8 *)&tmpSpare,(__u8 *)spare,sizeof(yaffs_spare));
+                ynorif1_AndBytes((u8 *)&tmpSpare,(u8 *)spare,sizeof(struct yaffs_spare));
                 
-                ynorif1_FlashWrite32(spareAddr,(__u32 *)&tmpSpare,16/ 4);
+                ynorif1_FlashWrite32(spareAddr,(u32 *)&tmpSpare,16/ 4);
         }
         else {
                 YBUG();
@@ -206,20 +204,20 @@ int ynorif1_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, c
 
 }
 
-int ynorif1_ReadChunkFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_spare *spare)
+int ynorif1_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_spare *spare)
 {
 
-       __u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
-       __u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
+       u32 *dataAddr = Chunk2DataAddr(dev,nand_chunk);
+       u32 *spareAddr = Chunk2SpareAddr(dev,nand_chunk);
        
        if(data)
        {
-               ynorif1_FlashRead32(dataAddr,(__u32 *)data,dev->param.total_bytes_per_chunk / 4);
+               ynorif1_FlashRead32(dataAddr,(u32 *)data,dev->param.total_bytes_per_chunk / 4);
        }
        
         if(spare)
         {
-                ynorif1_FlashRead32(spareAddr,(__u32 *)spare,16/ 4);
+                ynorif1_FlashRead32(spareAddr,(u32 *)spare,16/ 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.
@@ -236,11 +234,11 @@ int ynorif1_ReadChunkFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs
 
 }
 
-static int ynorif1_FormatBlock(yaffs_dev_t *dev, int blockNumber)
+static int ynorif1_FormatBlock(struct yaffs_dev *dev, int blockNumber)
 {
-       __u32 *blockAddr = Block2Addr(dev,blockNumber);
-       __u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
-       __u32 formatValue = FORMAT_VALUE;
+       u32 *blockAddr = Block2Addr(dev,blockNumber);
+       u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
+       u32 formatValue = FORMAT_VALUE;
        
        ynorif1_FlashEraseBlock(blockAddr);
        ynorif1_FlashWrite32(formatAddr,&formatValue,1);
@@ -248,20 +246,20 @@ static int ynorif1_FormatBlock(yaffs_dev_t *dev, int blockNumber)
        return YAFFS_OK;
 }
 
-static int ynorif1_UnformatBlock(yaffs_dev_t *dev, int blockNumber)
+static int ynorif1_UnformatBlock(struct yaffs_dev *dev, int blockNumber)
 {
-       __u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
-       __u32 formatValue = 0;
+       u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
+       u32 formatValue = 0;
        
        ynorif1_FlashWrite32(formatAddr,&formatValue,1);
        
        return YAFFS_OK;
 }
 
-static int ynorif1_IsBlockFormatted(yaffs_dev_t *dev, int blockNumber)
+static int ynorif1_IsBlockFormatted(struct yaffs_dev *dev, int blockNumber)
 {
-       __u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
-       __u32 formatValue;
+       u32 *formatAddr = Block2FormatAddr(dev,blockNumber);
+       u32 formatValue;
        
        
        ynorif1_FlashRead32(formatAddr,&formatValue,1);
@@ -269,7 +267,7 @@ static int ynorif1_IsBlockFormatted(yaffs_dev_t *dev, int blockNumber)
        return (formatValue == FORMAT_VALUE);
 }
 
-int ynorif1_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
+int ynorif1_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
 
        if(blockNumber < 0 || blockNumber >= BLOCKS_IN_DEVICE)
@@ -286,7 +284,7 @@ int ynorif1_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
        
 }
 
-int ynorif1_InitialiseNAND(yaffs_dev_t *dev)
+int ynorif1_InitialiseNAND(struct yaffs_dev *dev)
 {
        int i;
        
@@ -300,7 +298,7 @@ int ynorif1_InitialiseNAND(yaffs_dev_t *dev)
        return YAFFS_OK;
 }
 
-int ynorif1_Deinitialise_flash_fn(yaffs_dev_t *dev)
+int ynorif1_Deinitialise_flash_fn(struct yaffs_dev *dev)
 {
        dev=dev;        
        ynorif1_FlashDeinit();
index ac78423..71cb51f 100644 (file)
 
 #include "yaffs_guts.h"
 
-int ynorif1_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_spare *spare);
-int ynorif1_ReadChunkFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_spare *spare);
-int ynorif1_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber);
-int ynorif1_InitialiseNAND(yaffs_dev_t *dev);
-int ynorif1_Deinitialise_flash_fn(yaffs_dev_t *dev);
+int ynorif1_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_spare *spare);
+int ynorif1_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_spare *spare);
+int ynorif1_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber);
+int ynorif1_InitialiseNAND(struct yaffs_dev *dev);
+int ynorif1_Deinitialise_flash_fn(struct yaffs_dev *dev);
 
 #endif
 
index 9834bb2..babddde 100644 (file)
@@ -26,7 +26,6 @@ const char *yaffs_ramdisk_c_version = "$Id: yaffs_ramdisk.c,v 1.6 2010-01-11 04:
 
 #include "yaffs_ramdisk.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 #include "yaffs_packedtags1.h"
 
 
@@ -42,7 +41,7 @@ const char *yaffs_ramdisk_c_version = "$Id: yaffs_ramdisk.c,v 1.6 2010-01-11 04:
 
 typedef struct 
 {
-       __u8 data[528]; // Data + spare
+       u8 data[528]; // Data + spare
 } yramdisk_page;
 
 typedef struct
@@ -61,7 +60,7 @@ typedef struct
 
 static yramdisk_device ramdisk;
 
-static int  CheckInit(yaffs_dev_t *dev)
+static int  CheckInit(struct yaffs_dev *dev)
 {
        static int initialised = 0;
        
@@ -119,7 +118,7 @@ static int  CheckInit(yaffs_dev_t *dev)
        return 1;
 }
 
-int yramdisk_wr_chunk(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_ext_tags *tags)
+int yramdisk_wr_chunk(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_ext_tags *tags)
 {
        int blk;
        int pg;
@@ -139,7 +138,7 @@ int yramdisk_wr_chunk(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const ya
        
        if(tags)
        {
-               yaffs_packed_tags1 pt;
+               struct yaffs_packed_tags1 pt;
                
                yaffs_pack_tags1(&pt,tags);
                memcpy(&ramdisk.block[blk]->page[pg].data[512],&pt,sizeof(pt));
@@ -150,7 +149,7 @@ int yramdisk_wr_chunk(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const ya
 }
 
 
-int yramdisk_rd_chunk(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tags *tags)
+int yramdisk_rd_chunk(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_ext_tags *tags)
 {
        int blk;
        int pg;
@@ -170,7 +169,7 @@ int yramdisk_rd_chunk(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tag
        
        if(tags)
        {
-               yaffs_packed_tags1 pt;
+               struct yaffs_packed_tags1 pt;
                
                memcpy(&pt,&ramdisk.block[blk]->page[pg].data[512],sizeof(pt));
                yaffs_unpack_tags1(tags,&pt);
@@ -181,7 +180,7 @@ int yramdisk_rd_chunk(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tag
 }
 
 
-int yramdisk_check_chunk_erased(yaffs_dev_t *dev,int nand_chunk)
+int yramdisk_check_chunk_erased(struct yaffs_dev *dev,int nand_chunk)
 {
        int blk;
        int pg;
@@ -206,7 +205,7 @@ int yramdisk_check_chunk_erased(yaffs_dev_t *dev,int nand_chunk)
 
 }
 
-int yramdisk_erase(yaffs_dev_t *dev, int blockNumber)
+int yramdisk_erase(struct yaffs_dev *dev, int blockNumber)
 {
        
        CheckInit(dev);
@@ -224,7 +223,7 @@ int yramdisk_erase(yaffs_dev_t *dev, int blockNumber)
        
 }
 
-int yramdisk_initialise(yaffs_dev_t *dev)
+int yramdisk_initialise(struct yaffs_dev *dev)
 {
        //dev->use_nand_ecc = 1; // force on use_nand_ecc which gets faked. 
                                                 // This saves us doing ECC checks.
index c250bcc..1749c58 100644 (file)
 
 
 #include "yaffs_guts.h"
-int yramdisk_erase(yaffs_dev_t *dev, int blockNumber);
-int yramdisk_wr_chunk(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_ext_tags *tags);
-int yramdisk_rd_chunk(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tags *tags);
-int yramdisk_initialise(yaffs_dev_t *dev);
-int yramdisk_mark_block_bad(yaffs_dev_t *dev,int blockNumber);
-int yramdisk_query_block(yaffs_dev_t *dev, int block_no, yaffs_block_state_t *state, int *seq_number);
+int yramdisk_erase(struct yaffs_dev *dev, int blockNumber);
+int yramdisk_wr_chunk(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_ext_tags *tags);
+int yramdisk_rd_chunk(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_ext_tags *tags);
+int yramdisk_initialise(struct yaffs_dev *dev);
+int yramdisk_mark_block_bad(struct yaffs_dev *dev,int blockNumber);
+int yramdisk_query_block(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, int *seq_number);
 #endif
index 1a9765d..7f88b7c 100644 (file)
@@ -31,7 +31,6 @@ const char *yaffs_ramem2k_c_version = "$Id: yaffs_ramem2k.c,v 1.8 2010-02-18 01:
 
 #include "yaffs_nandemul2k.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 #include "yaffs_packedtags2.h"
 
 
@@ -54,7 +53,7 @@ const char *yaffs_ramem2k_c_version = "$Id: yaffs_ramem2k.c,v 1.8 2010-02-18 01:
 
 typedef struct 
 {
-       __u8 data[PAGE_TOTAL_SIZE]; // Data + spare
+       u8 data[PAGE_TOTAL_SIZE]; // Data + spare
        int empty;      // is this empty?
 } nandemul_Page;
 
@@ -190,13 +189,13 @@ static int  CheckInit(void)
        return 1;
 }
 
-int nandemul2k_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_ext_tags *tags)
+int nandemul2k_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_ext_tags *tags)
 {
        int blk;
        int pg;
        int i;
        
-       __u8 *x;
+       u8 *x;
 
        
        blk = nand_chunk/PAGES_PER_BLOCK;
@@ -220,7 +219,7 @@ int nandemul2k_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __
        {
                x = &ned.block[blk]->page[pg]->data[PAGE_DATA_SIZE];
                
-               yaffs_pack_tags2((yaffs_packed_tags2 *)x,tags, !dev->param.no_tags_ecc);
+               yaffs_pack_tags2((struct yaffs_packed_tags2 *)x,tags, !dev->param.no_tags_ecc);
                        
        }
        
@@ -233,12 +232,12 @@ int nandemul2k_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __
 }
 
 
-int nandemul2k_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tags *tags)
+int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_ext_tags *tags)
 {
        int blk;
        int pg;
        
-       __u8 *x;
+       u8 *x;
 
        
        
@@ -256,14 +255,14 @@ int nandemul2k_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *
        {
                x = &ned.block[blk]->page[pg]->data[PAGE_DATA_SIZE];
                
-               yaffs_unpack_tags2(tags,(yaffs_packed_tags2 *)x, !dev->param.no_tags_ecc);
+               yaffs_unpack_tags2(tags,(struct yaffs_packed_tags2 *)x, !dev->param.no_tags_ecc);
        }
 
        return YAFFS_OK;
 }
 
 
-static int nandemul2k_CheckChunkErased(yaffs_dev_t *dev,int nand_chunk)
+static int nandemul2k_CheckChunkErased(struct yaffs_dev *dev,int nand_chunk)
 {
        int blk;
        int pg;
@@ -287,7 +286,7 @@ static int nandemul2k_CheckChunkErased(yaffs_dev_t *dev,int nand_chunk)
 
 }
 
-int nandemul2k_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
+int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
        
        
@@ -307,29 +306,29 @@ int nandemul2k_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
        return YAFFS_OK;
 }
 
-int nandemul2k_InitialiseNAND(yaffs_dev_t *dev)
+int nandemul2k_InitialiseNAND(struct yaffs_dev *dev)
 {
        CheckInit();
        return YAFFS_OK;
 }
  
-int nandemul2k_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no)
+int nandemul2k_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no)
 {
        
-       __u8 *x;
+       u8 *x;
        
        x = &ned.block[block_no]->page[0]->data[PAGE_DATA_SIZE];
        
-       memset(x,0,sizeof(yaffs_packed_tags2));
+       memset(x,0,sizeof(struct yaffs_packed_tags2));
        
        
        return YAFFS_OK;
        
 }
 
-int nandemul2k_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no, yaffs_block_state_t *state, __u32  *seq_number)
+int nandemul2k_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, u32  *seq_number)
 {
-       yaffs_ext_tags tags;
+       struct yaffs_ext_tags tags;
        int chunkNo;
 
        *seq_number = 0;
index 590cb87..ce86587 100644 (file)
@@ -42,7 +42,7 @@ void yaffsfs_Unlock(void)
 {
 }
 
-__u32 yaffsfs_CurrentTime(void)
+u32 yaffsfs_CurrentTime(void)
 {
        return 0;
 }
@@ -67,16 +67,16 @@ void yaffsfs_LocalInitialisation(void)
 // /boot 2MB boot disk (flash)
 // /flash 14MB flash disk (flash)
 // NB Though /boot and /flash occupy the same physical device they
-// are still disticnt "yaffs_dev_ts. You may think of these as "partitions"
+// are still disticnt "struct yaffs_devs. You may think of these as "partitions"
 // using non-overlapping areas in the same device.
 // 
 
 #include "yaffs_ramdisk.h"
 #include "yaffs_flashif.h"
 
-static yaffs_dev_t ramDev;
-static yaffs_dev_t bootDev;
-static yaffs_dev_t flashDev;
+static struct yaffs_dev ramDev;
+static struct yaffs_dev bootDev;
+static struct yaffs_dev flashDev;
 
 static yaffsfs_DeviceConfiguration yaffsfs_config[] = {
 
index de8953e..6f7d212 100644 (file)
@@ -65,7 +65,7 @@ void yaffsfs_Unlock(void)
 {
 }
 
-__u32 yaffsfs_CurrentTime(void)
+u32 yaffsfs_CurrentTime(void)
 {
        return 0;
 }
@@ -106,9 +106,9 @@ void yaffsfs_LocalInitialisation(void)
 #include "yaffs_flashif2.h"
 #include "yaffs_nandemul2k.h"
 
-struct yaffs_dev_s ram1Dev;
-struct yaffs_dev_s flashDev;
-struct yaffs_dev_s m18_1Dev;
+struct yaffs_dev ram1Dev;
+struct yaffs_dev flashDev;
+struct yaffs_dev m18_1Dev;
 
 int yaffs_start_up(void)
 {
index a3548ef..60dcf02 100644 (file)
@@ -59,7 +59,7 @@ void yaffsfs_Unlock(void)
 {
 }
 
-__u32 yaffsfs_CurrentTime(void)
+u32 yaffsfs_CurrentTime(void)
 {
        return 0;
 }
index ab72d28..3965101 100644 (file)
@@ -48,7 +48,7 @@
 #define YNORSIM_DEV_SIZE_U32   (8*1024 * 1024/4)
 #endif
 
-static __u32 word[YNORSIM_DEV_SIZE_U32];
+static u32 word[YNORSIM_DEV_SIZE_U32];
 
 extern int random_seed;
 extern int simulate_power_failure;
@@ -111,7 +111,7 @@ static void ynorsim_ready(void)
   ynorsim_restore_image();
 }
 
-void ynorsim_rd32(__u32 *addr,__u32 *buf, int nwords)
+void ynorsim_rd32(u32 *addr,u32 *buf, int nwords)
 { 
    while(nwords > 0){
      *buf = *addr;
@@ -121,10 +121,10 @@ void ynorsim_rd32(__u32 *addr,__u32 *buf, int nwords)
    }
 }
 
-void ynorsim_wr_one_word32(__u32 *addr,__u32 val)
+void ynorsim_wr_one_word32(u32 *addr,u32 val)
 {
-  __u32 tmp;
-  __u32 m;
+  u32 tmp;
+  u32 m;
   int i;
 
   tmp = *addr;
@@ -148,7 +148,7 @@ void ynorsim_wr_one_word32(__u32 *addr,__u32 val)
   ynorsim_maybe_power_fail();
 }
 
-void ynorsim_wr32(__u32 *addr, __u32 *buf, int nwords)
+void ynorsim_wr32(u32 *addr, u32 *buf, int nwords)
 {
   while(nwords >0){
     ynorsim_wr_one_word32(addr,*buf);
@@ -158,7 +158,7 @@ void ynorsim_wr32(__u32 *addr, __u32 *buf, int nwords)
   }
 }
 
-void ynorsim_erase(__u32 *addr)
+void ynorsim_erase(u32 *addr)
 {
   /* Todo... bit flipping */
   memset(addr,0xFF,YNORSIM_BLOCK_SIZE_U32 * 4);
@@ -175,7 +175,7 @@ void ynorsim_shutdown(void)
   initialised=0;
 }
 
-__u32 *ynorsim_get_base(void)
+u32 *ynorsim_get_base(void)
 {
   return word;
 }
index e0e92b1..ca5bdf1 100644 (file)
 
 #include "yaffs_guts.h"
 
-void ynorsim_rd32(__u32 *addr, __u32 *data, int nwords);
-void ynorsim_wr32(__u32 *addr, __u32 *data, int nwords);
-void ynorsim_erase(__u32 *addr);
+void ynorsim_rd32(u32 *addr, u32 *data, int nwords);
+void ynorsim_wr32(u32 *addr, u32 *data, int nwords);
+void ynorsim_erase(u32 *addr);
 void ynorsim_shutdown(void);
 void ynorsim_initialise(void);
-__u32 * ynorsim_get_base(void);
+u32 * ynorsim_get_base(void);
 
 #endif
index 74d5f73..9b50a39 100644 (file)
@@ -41,7 +41,7 @@ typedef struct {
 
 SimData *simDevs[N_RAM_SIM_DEVS];
 
-static SimData *DevToSim(yaffs_dev_t *dev)
+static SimData *DevToSim(struct yaffs_dev *dev)
 {
        ynandif_Geometry *geom = (ynandif_Geometry *)(dev->driver_context);
        SimData * sim = (SimData*)(geom->privateData);
@@ -77,7 +77,7 @@ static int yramsim_erase_internal(SimData *sim, unsigned blockId,int force)
 
 
 
-static int yramsim_initialise(yaffs_dev_t *dev)
+static int yramsim_initialise(struct yaffs_dev *dev)
 {
        SimData *sim = DevToSim(dev);
        Block **blockList = sim->blockList;
@@ -85,12 +85,12 @@ static int yramsim_initialise(yaffs_dev_t *dev)
 }
 
 
-static int yramsim_deinitialise(yaffs_dev_t *dev)
+static int yramsim_deinitialise(struct yaffs_dev *dev)
 {
        return 1;
 }
 
-static int yramsim_rd_chunk (yaffs_dev_t *dev, unsigned pageId,
+static int yramsim_rd_chunk (struct yaffs_dev *dev, unsigned pageId,
                                          unsigned char *data, unsigned dataLength,
                                          unsigned char *spare, unsigned spareLength,
                                          int *eccStatus)
@@ -125,7 +125,7 @@ static int yramsim_rd_chunk (yaffs_dev_t *dev, unsigned pageId,
        return 1;
 }
 
-static int yramsim_wr_chunk (yaffs_dev_t *dev,unsigned pageId,
+static int yramsim_wr_chunk (struct yaffs_dev *dev,unsigned pageId,
                                           const unsigned char *data, unsigned dataLength,
                                           const unsigned char *spare, unsigned spareLength)
 {
@@ -157,7 +157,7 @@ static int yramsim_wr_chunk (yaffs_dev_t *dev,unsigned pageId,
 }
 
 
-static int yramsim_erase(yaffs_dev_t *dev,unsigned blockId)
+static int yramsim_erase(struct yaffs_dev *dev,unsigned blockId)
 {
        SimData *sim = DevToSim(dev);
 
@@ -165,7 +165,7 @@ static int yramsim_erase(yaffs_dev_t *dev,unsigned blockId)
        return yramsim_erase_internal(sim,blockId,0);
 }
 
-static int yramsim_check_block_ok(yaffs_dev_t *dev,unsigned blockId)
+static int yramsim_check_block_ok(struct yaffs_dev *dev,unsigned blockId)
 {
        SimData *sim = DevToSim(dev);
        Block **blockList = sim->blockList;
@@ -176,7 +176,7 @@ static int yramsim_check_block_ok(yaffs_dev_t *dev,unsigned blockId)
        return blockList[blockId]->blockOk ? 1 : 0;
 }
 
-static int yramsim_mark_block_bad(yaffs_dev_t *dev,unsigned blockId)
+static int yramsim_mark_block_bad(struct yaffs_dev *dev,unsigned blockId)
 {
        SimData *sim = DevToSim(dev);
        Block **blockList = sim->blockList;
@@ -190,14 +190,14 @@ static int yramsim_mark_block_bad(yaffs_dev_t *dev,unsigned blockId)
 }
 
 
-static SimData *yramsim_alloc_sim_data(__u32 devId, __u32 nBlocks)
+static SimData *yramsim_alloc_sim_data(u32 devId, u32 nBlocks)
 {
        int ok = 1;
 
        Block **blockList;
        SimData *sim;
        Block *b;
-       __u32 i;
+       u32 i;
 
        if(devId >= N_RAM_SIM_DEVS)
                return NULL;
@@ -251,9 +251,9 @@ static SimData *yramsim_alloc_sim_data(__u32 devId, __u32 nBlocks)
 }
 
 
-struct yaffs_dev_s *yramsim_CreateRamSim(const YCHAR *name,
-                               __u32 devId, __u32 nBlocks,
-                               __u32 start_block, __u32 end_block)
+struct yaffs_dev *yramsim_CreateRamSim(const YCHAR *name,
+                               u32 devId, u32 nBlocks,
+                               u32 start_block, u32 end_block)
 {
        SimData *sim;
        ynandif_Geometry *g;
index 4f20364..b27b69f 100644 (file)
@@ -23,9 +23,9 @@
 
 #define N_RAM_SIM_DEVS  2
 
-struct yaffs_dev_s *yramsim_CreateRamSim(const YCHAR *name,
-                                               __u32 devId, __u32 nBlocks,
-                                               __u32 start_block, __u32 end_block);
+struct yaffs_dev *yramsim_CreateRamSim(const YCHAR *name,
+                                               u32 devId, u32 nBlocks,
+                                               u32 start_block, u32 end_block);
 
 #endif
 
index f2eac15..7c7a063 100644 (file)
@@ -30,7 +30,7 @@ CFLAGS +=    -O0 -fPIC
 
 
 COMMONTESTOBJS = yaffscfg2k.o yramsim.o yaffs_fileem2k.o\
-                yaffs_nandif.o \
+                yaffs_nandif.o yaffs_attribs.o \
                 yaffsfs.o  yaffs_ecc.o yaffs_guts.o \
                 yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
                 yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
@@ -47,12 +47,12 @@ YAFFSLIBOBJS  = $(COMMONTESTOBJS) yaffs_python_helper.o yaffs_error_converter.o
 
 
 
-YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
           yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  \
-          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h yaffs_list.h \
+          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h  \
           yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
-          yaffs_nameval.c yaffs_nameval.h \
-          yaffs_qsort.h yaffs_trace.h \
+          yaffs_nameval.c yaffs_nameval.h yaffs_attribs.h \
+          yaffs_trace.h \
           yaffs_allocator.c yaffs_allocator.h \
           yaffs_yaffs1.c yaffs_yaffs1.h \
           yaffs_yaffs2.c yaffs_yaffs2.h \
@@ -61,8 +61,9 @@ YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yp
           
 
 YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffsfs.h yaffscfg.h yaffs_malloc.h ydirectenv.h \
-                      yaffs_flashif.c yaffs_flashif.h yaffs_flashif2.h\
-                      yaffs_nandif.c yaffs_nandif.h yaffs_qsort.c yaffs_nandemul2k.h
+                      yaffs_flashif.c yaffs_flashif.h yaffs_flashif2.h yaffs_list.h \
+                      yaffs_nandif.c yaffs_nandif.h yaffs_qsort.c yaffs_nandemul2k.h \
+                      yportenv.h yaffs_attribs.c
 
 DIRECTEXTRASYMLINKS =   yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
                         yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
index 5800b0a..016b934 100644 (file)
@@ -34,7 +34,7 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf
                 yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
                 yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
                 yaffs_checkptrw.o  yaffs_qsort.o\
-                yaffs_nameval.o \
+                yaffs_nameval.o yaffs_attribs.o \
                 yaffs_norif1.o  ynorsim.o nor_stress.o yaffs_fsx.o \
                 yaffs_allocator.o \
                 yaffs_bitmap.o \
@@ -49,12 +49,12 @@ YAFFSTESTOBJS  = $(COMMONTESTOBJS) yaffs_test.o
 
 ALLOBJS = $(sort $(YAFFSTESTOBJS))
 
-YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \
           yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  yaffs_nandemul2k.h \
-          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h yaffs_list.h \
+          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \
           yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
           yaffs_nameval.c yaffs_nameval.h \
-          yaffs_qsort.h yaffs_trace.h \
+          yaffs_trace.h yaffs_attribs.h \
           yaffs_allocator.c yaffs_allocator.h \
           yaffs_yaffs1.c yaffs_yaffs1.h \
           yaffs_yaffs2.c yaffs_yaffs2.h \
@@ -64,8 +64,9 @@ YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yp
 YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
                       yaffsfs.h yaffs_malloc.h ydirectenv.h \
                       yaffs_flashif.c yaffscfg.h yaffs_qsort.c \
-                      yaffs_nandemul2k.h \
-                      yaffs_nandif.c yaffs_nandif.h
+                      yaffs_nandemul2k.h yaffs_list.h \
+                      yaffs_attribs.c \
+                      yaffs_nandif.c yaffs_nandif.h yportenv.h
 
 
 DIRECTEXTRASYMLINKS =  yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
diff --git a/direct/yaffs_attribs.c b/direct/yaffs_attribs.c
new file mode 100644 (file)
index 0000000..89cd7fc
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "yaffs_attribs.h"
+
+
+void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
+{
+       obj->yst_uid = oh->yst_uid;
+       obj->yst_gid = oh->yst_gid;
+       obj->yst_atime = oh->yst_atime;
+       obj->yst_mtime = oh->yst_mtime;
+       obj->yst_ctime = oh->yst_ctime;
+       obj->yst_rdev = oh->yst_rdev;
+}
+
+
+void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj)
+{
+#ifdef CONFIG_YAFFS_WINCE
+               oh->win_atime[0] = obj->win_atime[0];
+               oh->win_ctime[0] = obj->win_ctime[0];
+               oh->win_mtime[0] = obj->win_mtime[0];
+               oh->win_atime[1] = obj->win_atime[1];
+               oh->win_ctime[1] = obj->win_ctime[1];
+               oh->win_mtime[1] = obj->win_mtime[1];
+#else
+               oh->yst_uid = obj->yst_uid;
+               oh->yst_gid = obj->yst_gid;
+               oh->yst_atime = obj->yst_atime;
+               oh->yst_mtime = obj->yst_mtime;
+               oh->yst_ctime = obj->yst_ctime;
+               oh->yst_rdev = obj->yst_rdev;
+#endif
+
+}
+
+void yaffs_attribs_init(struct yaffs_obj *obj, u32 gid, u32 uid, u32 rdev)
+{
+
+#ifdef CONFIG_YAFFS_WINCE
+               yfsd_win_file_time_now(obj->win_atime);
+               obj->win_ctime[0] = obj->win_mtime[0] = obj->win_atime[0];
+               obj->win_ctime[1] = obj->win_mtime[1] = obj->win_atime[1];
+
+#else
+       yaffs_load_current_time(obj,1,1);
+       obj->yst_rdev = rdev;
+       obj->yst_uid = uid;
+       obj->yst_gid = gid;
+#endif
+}
+
+void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c)
+{
+#ifdef CONFIG_YAFFS_WINCE
+               yfsd_win_file_time_now(the_obj->win_atime);
+               the_obj->win_ctime[0] = the_obj->win_mtime[0] =
+                   the_obj->win_atime[0];
+               the_obj->win_ctime[1] = the_obj->win_mtime[1] =
+                   the_obj->win_atime[1];
+
+#else
+
+        obj->yst_mtime = Y_CURRENT_TIME;
+        if(do_a)
+                obj->yst_atime = obj->yst_atime;
+        if(do_c)
+                obj->yst_ctime = obj->yst_atime;
+#endif
+}
+
+loff_t yaffs_get_file_size(struct yaffs_obj *obj)
+{
+       YCHAR *alias = NULL;
+       obj = yaffs_get_equivalent_obj(obj);
+
+       switch (obj->variant_type) {
+       case YAFFS_OBJECT_TYPE_FILE:
+               return obj->variant.file_variant.file_size;
+       case YAFFS_OBJECT_TYPE_SYMLINK:
+               alias = obj->variant.symlink_variant.alias;
+               if(!alias)
+                       return 0;
+               return yaffs_strnlen(alias,YAFFS_MAX_ALIAS_LENGTH);
+       default:
+               return 0;
+       }
+}
+
+int yaffs_set_attribs(struct yaffs_obj *obj, struct iattr *attr)
+{
+       unsigned int valid = attr->ia_valid;
+
+       if (valid & ATTR_MODE)
+               obj->yst_mode = attr->ia_mode;
+       if (valid & ATTR_UID)
+               obj->yst_uid = attr->ia_uid;
+       if (valid & ATTR_GID)
+               obj->yst_gid = attr->ia_gid;
+
+       if (valid & ATTR_ATIME)
+               obj->yst_atime = Y_TIME_CONVERT(attr->ia_atime);
+       if (valid & ATTR_CTIME)
+               obj->yst_ctime = Y_TIME_CONVERT(attr->ia_ctime);
+       if (valid & ATTR_MTIME)
+               obj->yst_mtime = Y_TIME_CONVERT(attr->ia_mtime);
+
+       if (valid & ATTR_SIZE)
+               yaffs_resize_file(obj, attr->ia_size);
+
+       yaffs_update_oh(obj, NULL, 1, 0, 0, NULL);
+
+       return YAFFS_OK;
+
+}
+
+int yaffs_get_attribs(struct yaffs_obj *obj, struct iattr *attr)
+{
+       unsigned int valid = 0;
+
+       attr->ia_mode = obj->yst_mode;
+       valid |= ATTR_MODE;
+       attr->ia_uid = obj->yst_uid;
+       valid |= ATTR_UID;
+       attr->ia_gid = obj->yst_gid;
+       valid |= ATTR_GID;
+
+       Y_TIME_CONVERT(attr->ia_atime) = obj->yst_atime;
+       valid |= ATTR_ATIME;
+       Y_TIME_CONVERT(attr->ia_ctime) = obj->yst_ctime;
+       valid |= ATTR_CTIME;
+       Y_TIME_CONVERT(attr->ia_mtime) = obj->yst_mtime;
+       valid |= ATTR_MTIME;
+
+       attr->ia_size = yaffs_get_file_size(obj);
+       valid |= ATTR_SIZE;
+
+       attr->ia_valid = valid;
+
+       return YAFFS_OK;
+}
+
index 79732a1..8595804 100644 (file)
@@ -19,7 +19,6 @@ const char *yaffs_flashif_c_version = "$Id: yaffs_flashif.c,v 1.3 2007-02-14 01:
 
 #include "yaffs_flashif.h"
 #include "yaffs_guts.h"
-#include "devextras.h"
 
 
 #define SIZE_IN_MB 16
@@ -31,7 +30,7 @@ const char *yaffs_flashif_c_version = "$Id: yaffs_flashif.c,v 1.3 2007-02-14 01:
 
 typedef struct 
 {
-       __u8 data[528]; // Data + spare
+       u8 data[528]; // Data + spare
 } yflash_Page;
 
 typedef struct
@@ -50,7 +49,7 @@ typedef struct
 
 static yflash_Device ramdisk;
 
-static int  CheckInit(yaffs_dev_t *dev)
+static int  CheckInit(struct yaffs_dev *dev)
 {
        static int initialised = 0;
        
@@ -108,7 +107,7 @@ static int  CheckInit(yaffs_dev_t *dev)
        return 1;
 }
 
-int yflash_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, yaffs_ext_tags *tags)
+int yflash_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, struct yaffs_ext_tags *tags)
 {
        int blk;
        int pg;
@@ -138,7 +137,7 @@ int yflash_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *
 }
 
 
-int yflash_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_tags_t *tags)
+int yflash_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_tags *tags)
 {
        int blk;
        int pg;
@@ -167,7 +166,7 @@ int yflash_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data
 }
 
 
-int yflash_CheckChunkErased(yaffs_dev_t *dev,int nand_chunk)
+int yflash_CheckChunkErased(struct yaffs_dev *dev,int nand_chunk)
 {
        int blk;
        int pg;
@@ -192,7 +191,7 @@ int yflash_CheckChunkErased(yaffs_dev_t *dev,int nand_chunk)
 
 }
 
-int yflash_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
+int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
 {
        
        CheckInit(dev);
@@ -210,19 +209,19 @@ int yflash_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber)
        
 }
 
-int yflash_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no)
+int yflash_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no)
 {
        return YAFFS_OK;
        
 }
-int yflash_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no, yaffs_block_state_t *state, int *seq_number)
+int yflash_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, int *seq_number)
 {
        *state = YAFFS_BLOCK_STATE_EMPTY;
        *seq_number = 0;
 }
 
 
-int yflash_InitialiseNAND(yaffs_dev_t *dev)
+int yflash_InitialiseNAND(struct yaffs_dev *dev)
 {
        return YAFFS_OK;
 }
index bc3ed70..b169170 100644 (file)
 
 
 #include "yaffs_guts.h"
-int yflash_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber);
-int yflash_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_spare *spare);
-int yflash_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_ext_tags *tags);
-int yflash_ReadChunkFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_spare *spare);
-int yflash_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tags *tags);
-int yflash_InitialiseNAND(yaffs_dev_t *dev);
-int yflash_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no);
-int yflash_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no, yaffs_block_state_t *state, __u32 *seq_number);
+int yflash_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber);
+int yflash_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_spare *spare);
+int yflash_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_ext_tags *tags);
+int yflash_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_spare *spare);
+int yflash_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_ext_tags *tags);
+int yflash_InitialiseNAND(struct yaffs_dev *dev);
+int yflash_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no);
+int yflash_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, u32 *seq_number);
 
 #endif
index de82085..75a66de 100644 (file)
 
 
 #include "yaffs_guts.h"
-int yflash2_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber);
-int yflash2_WriteChunkToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_spare *spare);
-int yflash2_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_ext_tags *tags);
-int yflash2_ReadChunkFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_spare *spare);
-int yflash2_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tags *tags);
-int yflash2_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber);
-int yflash2_InitialiseNAND(yaffs_dev_t *dev);
-int yflash2_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no);
-int yflash2_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no, yaffs_block_state_t *state, __u32 *seq_number);
+int yflash2_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber);
+int yflash2_WriteChunkToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_spare *spare);
+int yflash2_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_ext_tags *tags);
+int yflash2_ReadChunkFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_spare *spare);
+int yflash2_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_ext_tags *tags);
+int yflash2_InitialiseNAND(struct yaffs_dev *dev);
+int yflash2_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no);
+int yflash2_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, u32 *seq_number);
 
 #endif
similarity index 64%
rename from yaffs_list.h
rename to direct/yaffs_list.h
index 145a1c5..624cd5f 100644 (file)
  * way the Linux kernel doubly linked list implementation works.
  */
 
-struct ylist_head {
-       struct ylist_head *next; /* next in chain */
-       struct ylist_head *prev; /* previous in chain */
+struct list_head {
+       struct list_head *next; /* next in chain */
+       struct list_head *prev; /* previous in chain */
 };
 
 
 /* Initialise a static list */
-#define YLIST_HEAD(name) \
-struct ylist_head name = { &(name), &(name)}
+#define LIST_HEAD(name) \
+struct list_head name = { &(name), &(name)}
 
 
 
 /* Initialise a list head to an empty list */
-#define YINIT_LIST_HEAD(p) \
+#define INIT_LIST_HEAD(p) \
 do { \
        (p)->next = (p);\
        (p)->prev = (p); \
@@ -52,10 +52,10 @@ do { \
 
 
 /* Add an element to a list */
-static Y_INLINE void ylist_add(struct ylist_head *new_entry,
-                               struct ylist_head *list)
+static Y_INLINE void list_add(struct list_head *new_entry,
+                               struct list_head *list)
 {
-       struct ylist_head *list_next = list->next;
+       struct list_head *list_next = list->next;
 
        list->next = new_entry;
        new_entry->prev = list;
@@ -64,10 +64,10 @@ static Y_INLINE void ylist_add(struct ylist_head *new_entry,
 
 }
 
-static Y_INLINE void ylist_add_tail(struct ylist_head *new_entry,
-                                struct ylist_head *list)
+static Y_INLINE void list_add_tail(struct list_head *new_entry,
+                                struct list_head *list)
 {
-       struct ylist_head *list_prev = list->prev;
+       struct list_head *list_prev = list->prev;
 
        list->prev = new_entry;
        new_entry->next = list;
@@ -79,47 +79,47 @@ static Y_INLINE void ylist_add_tail(struct ylist_head *new_entry,
 
 /* Take an element out of its current list, with or without
  * reinitialising the links.of the entry*/
-static Y_INLINE void ylist_del(struct ylist_head *entry)
+static Y_INLINE void list_del(struct list_head *entry)
 {
-       struct ylist_head *list_next = entry->next;
-       struct ylist_head *list_prev = entry->prev;
+       struct list_head *list_next = entry->next;
+       struct list_head *list_prev = entry->prev;
 
        list_next->prev = list_prev;
        list_prev->next = list_next;
 
 }
 
-static Y_INLINE void ylist_del_init(struct ylist_head *entry)
+static Y_INLINE void list_del_init(struct list_head *entry)
 {
-       ylist_del(entry);
+       list_del(entry);
        entry->next = entry->prev = entry;
 }
 
 
 /* Test if the list is empty */
-static Y_INLINE int ylist_empty(struct ylist_head *entry)
+static Y_INLINE int list_empty(struct list_head *entry)
 {
        return (entry->next == entry);
 }
 
 
-/* ylist_entry takes a pointer to a list entry and offsets it to that
+/* list_entry takes a pointer to a list entry and offsets it to that
  * we can find a pointer to the object it is embedded in.
  */
 
 
-#define ylist_entry(entry, type, member) \
+#define list_entry(entry, type, member) \
        ((type *)((char *)(entry)-(unsigned long)(&((type *)NULL)->member)))
 
 
-/* ylist_for_each and list_for_each_safe  iterate over lists.
- * ylist_for_each_safe uses temporary storage to make the list delete safe
+/* list_for_each and list_for_each_safe  iterate over lists.
+ * list_for_each_safe uses temporary storage to make the list delete safe
  */
 
-#define ylist_for_each(itervar, list) \
+#define list_for_each(itervar, list) \
        for (itervar = (list)->next; itervar != (list); itervar = itervar->next)
 
-#define ylist_for_each_safe(itervar, save_var, list) \
+#define list_for_each_safe(itervar, save_var, list) \
        for (itervar = (list)->next, save_var = (list)->next->next; \
                itervar != (list); itervar = save_var, save_var = save_var->next)
 
index 30b7cbd..739e118 100644 (file)
 
 #include "yaffs_guts.h"
 
-int nandemul2k_WriteChunkWithTagsToNAND(struct yaffs_dev_s *dev,
-                                       int nand_chunk, const __u8 *data,
-                                       const yaffs_ext_tags *tags);
-int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_dev_s *dev,
-                                        int nand_chunk, __u8 *data,
-                                        yaffs_ext_tags *tags);
-int nandemul2k_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no);
-int nandemul2k_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no,
-                             yaffs_block_state_t *state, __u32 *seq_number);
-int nandemul2k_EraseBlockInNAND(struct yaffs_dev_s *dev,
+int nandemul2k_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,
+                                       int nand_chunk, const u8 *data,
+                                       const struct yaffs_ext_tags *tags);
+int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,
+                                        int nand_chunk, u8 *data,
+                                        struct yaffs_ext_tags *tags);
+int nandemul2k_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no);
+int nandemul2k_QueryNANDBlock(struct yaffs_dev *dev, int block_no,
+                             enum yaffs_block_state *state, u32 *seq_number);
+int nandemul2k_EraseBlockInNAND(struct yaffs_dev *dev,
                                int flash_block);
-int nandemul2k_InitialiseNAND(struct yaffs_dev_s *dev);
+int nandemul2k_InitialiseNAND(struct yaffs_dev *dev);
 int nandemul2k_GetBytesPerChunk(void);
 int nandemul2k_GetChunksPerBlock(void);
 int nandemul2k_GetNumberOfBlocks(void);
index 135e894..9a22f7f 100644 (file)
@@ -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_packed_tags2 pt;
+       struct yaffs_packed_tags2 pt;
        void *spare;
        unsigned spareSize = 0;
        ynandif_Geometry *geometry = (ynandif_Geometry *)(dev->driver_context);
@@ -52,8 +51,8 @@ int ynandif_WriteChunkWithTagsToNAND(yaffs_dev_t * dev, int nand_chunk,
         */
 
        if(dev->param.inband_tags){
-               yaffs_packed_tags2_tags_only *pt2tp;
-               pt2tp = (yaffs_packed_tags2_tags_only *)(data + dev->data_bytes_per_chunk);
+               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;
@@ -61,7 +60,7 @@ int ynandif_WriteChunkWithTagsToNAND(yaffs_dev_t * dev, int nand_chunk,
        else{
                yaffs_pack_tags2(&pt, tags,!dev->param.no_tags_ecc);
                spare = &pt;
-               spareSize = sizeof(yaffs_packed_tags2);
+               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_packed_tags2 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_packed_tags2);
+               spareSize = sizeof(struct yaffs_packed_tags2);
        }
 
        retval = geometry->readChunk(dev,nand_chunk,
@@ -111,8 +110,8 @@ int ynandif_ReadChunkWithTagsFromNAND(yaffs_dev_t * dev, int nand_chunk,
 
        if(dev->param.inband_tags){
                if(tags){
-                       yaffs_packed_tags2_tags_only * pt2tp;
-                       pt2tp = (yaffs_packed_tags2_tags_only *)&data[dev->data_bytes_per_chunk];       
+                       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);
                }
        }
@@ -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;
index b8e3ba0..a130f3c 100644 (file)
@@ -30,43 +30,43 @@ typedef struct {
        unsigned inband_tags;
        unsigned useYaffs2;
 
-       int (*initialise)(yaffs_dev_t *dev);
-       int (*deinitialise)(yaffs_dev_t *dev);
+       int (*initialise)(struct yaffs_dev *dev);
+       int (*deinitialise)(struct yaffs_dev *dev);
 
-       int (*readChunk) (yaffs_dev_t *dev,
+       int (*readChunk) (struct yaffs_dev *dev,
                                          unsigned pageId, 
                                          unsigned char *data, unsigned dataLength,
                                          unsigned char *spare, unsigned spareLength,
                                          int *eccStatus);
 // ECC status is set to 0 for OK, 1 for fixed, -1 for unfixed.
 
-       int (*writeChunk)(yaffs_dev_t *dev,
+       int (*writeChunk)(struct yaffs_dev *dev,
                                          unsigned pageId, 
                                          const unsigned char *data, unsigned dataLength,
                                          const unsigned char *spare, unsigned spareLength);
 
-       int (*eraseBlock)(yaffs_dev_t *dev, unsigned blockId);
+       int (*eraseBlock)(struct yaffs_dev *dev, unsigned blockId);
 
-       int (*checkBlockOk)(yaffs_dev_t *dev, unsigned blockId);
-       int (*markBlockBad)(yaffs_dev_t *dev, unsigned blockId);
+       int (*checkBlockOk)(struct yaffs_dev *dev, unsigned blockId);
+       int (*markBlockBad)(struct yaffs_dev *dev, unsigned blockId);
 
        void *privateData;
 
 } ynandif_Geometry;
 
-struct yaffs_dev_s * 
+struct yaffs_dev * 
        yaffs_add_dev_from_geometry(const YCHAR *name,
                                        const ynandif_Geometry *geometry);
 
 #if 0
 
-int ynandif_WriteChunkWithTagsToNAND(yaffs_dev_t *dev,int nand_chunk,const __u8 *data, const yaffs_ext_tags *tags);
-int ynandif_ReadChunkWithTagsFromNAND(yaffs_dev_t *dev,int nand_chunk, __u8 *data, yaffs_ext_tags *tags);
-int ynandif_EraseBlockInNAND(yaffs_dev_t *dev, int blockNumber);
-int ynandif_InitialiseNAND(yaffs_dev_t *dev);
-int ynandif_MarkNANDBlockBad(yaffs_dev_t *dev,int blockNumber);
-int ynandif_QueryNANDBlock(yaffs_dev_t *dev, int block_no, yaffs_block_state_t *state, __u32 *seq_number);
-int ynandif_GetGeometry(yaffs_dev_t *dev, ynandif_Geometry *geometry);
+int ynandif_WriteChunkWithTagsToNAND(struct yaffs_dev *dev,int nand_chunk,const u8 *data, const struct yaffs_ext_tags *tags);
+int ynandif_ReadChunkWithTagsFromNAND(struct yaffs_dev *dev,int nand_chunk, u8 *data, struct yaffs_ext_tags *tags);
+int ynandif_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber);
+int ynandif_InitialiseNAND(struct yaffs_dev *dev);
+int ynandif_MarkNANDBlockBad(struct yaffs_dev *dev,int blockNumber);
+int ynandif_QueryNANDBlock(struct yaffs_dev *dev, int block_no, enum yaffs_block_state *state, u32 *seq_number);
+int ynandif_GetGeometry(struct yaffs_dev *dev, ynandif_Geometry *geometry);
 #endif
 
 
index c4cd48b..42fd78c 100644 (file)
 #define __YAFFSCFG_H__
 
 
-#include "yportenv.h"
-#include "devextras.h"
+#include "yportenv.h"     
 
 #define YAFFSFS_N_HANDLES 100
 
 
 typedef struct yaffsfs_DeviceConfigurationStruct {
        const YCHAR *prefix;
-       struct yaffs_dev_s *dev;
+       struct yaffs_dev *dev;
 } yaffsfs_DeviceConfiguration;
 
 
 void yaffsfs_Lock(void);
 void yaffsfs_Unlock(void);
 
-__u32 yaffsfs_CurrentTime(void);
+u32 yaffsfs_CurrentTime(void);
 
 void yaffsfs_SetError(int err);
 
index 64a9491..b187142 100644 (file)
@@ -31,8 +31,8 @@
 #define YAFFSFS_RW_SIZE  (1<<YAFFSFS_RW_SHIFT)
 
 /* Some forward references */
-static yaffs_obj_t *yaffsfs_FindObject(yaffs_obj_t *relativeDirectory, const YCHAR *path, int symDepth, int getEquiv);
-static void yaffsfs_RemoveObjectCallback(yaffs_obj_t *obj);
+static struct yaffs_obj *yaffsfs_FindObject(struct yaffs_obj *relativeDirectory, const YCHAR *path, int symDepth, int getEquiv);
+static void yaffsfs_RemoveObjectCallback(struct yaffs_obj *obj);
 
 unsigned int yaffs_wr_attempts;
 
@@ -49,18 +49,18 @@ unsigned int yaffs_wr_attempts;
 
 typedef struct {
        int count;      /* Number of handles accessing this inode */
-       yaffs_obj_t *iObj;
+       struct yaffs_obj *iObj;
 } yaffsfs_Inode;
 
 typedef struct{
-       __u8    reading:1;
-       __u8    writing:1;
-       __u8    append:1;
-       __u8    shareRead:1;
-       __u8    shareWrite:1;
+       u8      reading:1;
+       u8      writing:1;
+       u8      append:1;
+       u8      shareRead:1;
+       u8      shareWrite:1;
        int     inodeId:12;     /* Index to corresponding yaffsfs_Inode */
        int     useCount:10;    /* Use count for this handle */
-       __u32 position;         /* current position in file */
+       u32 position;           /* current position in file */
 }yaffsfs_Handle;
 
 static yaffsfs_Inode yaffsfs_inode[YAFFSFS_N_HANDLES];
@@ -114,7 +114,7 @@ yaffsfs_Inode *yaffsfs_GetInodePointer(int handle)
        return NULL;
 }
 
-yaffs_obj_t *yaffsfs_GetHandleObject(int handle)
+struct yaffs_obj *yaffsfs_GetHandleObject(int handle)
 {
        yaffsfs_Inode *in = yaffsfs_GetInodePointer(handle);
 
@@ -129,7 +129,7 @@ yaffs_obj_t *yaffsfs_GetHandleObject(int handle)
  * Find the inode entry for an object, if it exists.
  */
 
-static int yaffsfs_FindInodeIdForObject(yaffs_obj_t *obj)
+static int yaffsfs_FindInodeIdForObject(struct yaffs_obj *obj)
 {
        int i;
        int ret = -1;
@@ -149,7 +149,7 @@ static int yaffsfs_FindInodeIdForObject(yaffs_obj_t *obj)
  * yaffsfs_GetInodeIdForObject
  * Grab an inode entry when opening a new inode.
  */
-static int yaffsfs_GetInodeIdForObject(yaffs_obj_t *obj)
+static int yaffsfs_GetInodeIdForObject(struct yaffs_obj *obj)
 {
        int i;
        int ret;
@@ -178,7 +178,7 @@ static int yaffsfs_GetInodeIdForObject(yaffs_obj_t *obj)
 }
 
 
-static int yaffsfs_CountHandles(yaffs_obj_t *obj)
+static int yaffsfs_CountHandles(struct yaffs_obj *obj)
 {
        int i = yaffsfs_FindInodeIdForObject(obj);
 
@@ -190,7 +190,7 @@ static int yaffsfs_CountHandles(yaffs_obj_t *obj)
 
 static void yaffsfs_ReleaseInode(yaffsfs_Inode *in)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
        
        obj = in->iObj;
 
@@ -302,7 +302,7 @@ int yaffsfs_IsPathDivider(YCHAR ch)
 
 
 
-YLIST_HEAD(yaffsfs_deviceList);
+LIST_HEAD(yaffsfs_deviceList);
 
 /*
  * yaffsfs_FindDevice
@@ -311,13 +311,13 @@ YLIST_HEAD(yaffsfs_deviceList);
  * Curveballs: Should match paths that end in '/' too
  * Curveball2 Might have "/x/ and "/x/y". Need to return the longest match
  */
-static yaffs_dev_t *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
+static struct yaffs_dev *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
 {
-       struct ylist_head *cfg;
+       struct list_head *cfg;
        const YCHAR *leftOver;
        const YCHAR *p;
-       yaffs_dev_t *retval = NULL;
-       yaffs_dev_t *dev = NULL;
+       struct yaffs_dev *retval = NULL;
+       struct yaffs_dev *dev = NULL;
        int thisMatchLength;
        int longestMatch = -1;
        int matching;
@@ -327,8 +327,8 @@ static yaffs_dev_t *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
         * 1) Actually matches a prefix (ie /a amd /abc will not match
         * 2) Matches the longest.
         */
-       ylist_for_each(cfg, &yaffsfs_deviceList){
-               dev = ylist_entry(cfg, yaffs_dev_t, dev_list);
+       list_for_each(cfg, &yaffsfs_deviceList){
+               dev = list_entry(cfg, struct yaffs_dev, dev_list);
                leftOver = path;
                p = dev->param.name;
                thisMatchLength = 0;
@@ -383,12 +383,12 @@ static yaffs_dev_t *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
 }
 
 #if 0
-static yaffs_dev_t *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
+static struct yaffs_dev *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
 {
        yaffsfs_DeviceConfiguration *cfg = yaffsfs_configurationList;
        const YCHAR *leftOver;
        const YCHAR *p;
-       yaffs_dev_t *retval = NULL;
+       struct yaffs_dev *retval = NULL;
        int thisMatchLength;
        int longestMatch = -1;
 
@@ -425,10 +425,10 @@ static yaffs_dev_t *yaffsfs_FindDevice(const YCHAR *path, YCHAR **restOfPath)
 }
 #endif
 
-static yaffs_obj_t *yaffsfs_FindRoot(const YCHAR *path, YCHAR **restOfPath)
+static struct yaffs_obj *yaffsfs_FindRoot(const YCHAR *path, YCHAR **restOfPath)
 {
 
-       yaffs_dev_t *dev;
+       struct yaffs_dev *dev;
 
        dev= yaffsfs_FindDevice(path,restOfPath);
        if(dev && dev->is_mounted){
@@ -437,7 +437,7 @@ static yaffs_obj_t *yaffsfs_FindRoot(const YCHAR *path, YCHAR **restOfPath)
        return NULL;
 }
 
-static yaffs_obj_t *yaffsfs_FollowLink(yaffs_obj_t *obj,int symDepth)
+static struct yaffs_obj *yaffsfs_FollowLink(struct yaffs_obj *obj,int symDepth)
 {
 
        if(obj)
@@ -463,10 +463,10 @@ static yaffs_obj_t *yaffsfs_FollowLink(yaffs_obj_t *obj,int symDepth)
  *
  * eg. "/data/xx/ff" --> puts name="ff" and returns the directory "/data/xx"
  */
-static yaffs_obj_t *yaffsfs_DoFindDirectory(yaffs_obj_t *startDir,
+static struct yaffs_obj *yaffsfs_DoFindDirectory(struct yaffs_obj *startDir,
                                const YCHAR *path, YCHAR **name, int symDepth)
 {
-       yaffs_obj_t *dir;
+       struct yaffs_obj *dir;
        YCHAR *restOfPath;
        YCHAR str[YAFFS_MAX_NAME_LENGTH+1];
        int i;
@@ -526,7 +526,7 @@ static yaffs_obj_t *yaffsfs_DoFindDirectory(yaffs_obj_t *startDir,
        return NULL;
 }
 
-static yaffs_obj_t *yaffsfs_FindDirectory(yaffs_obj_t *relativeDirectory,
+static struct yaffs_obj *yaffsfs_FindDirectory(struct yaffs_obj *relativeDirectory,
                                        const YCHAR *path,YCHAR **name,int symDepth)
 {
        return yaffsfs_DoFindDirectory(relativeDirectory,path,name,symDepth);
@@ -535,10 +535,10 @@ static yaffs_obj_t *yaffsfs_FindDirectory(yaffs_obj_t *relativeDirectory,
 /*
  * yaffsfs_FindObject turns a path for an existing object into the object
  */
-static yaffs_obj_t *yaffsfs_FindObject(yaffs_obj_t *relativeDirectory, const YCHAR *path,int symDepth, int getEquiv)
+static struct yaffs_obj *yaffsfs_FindObject(struct yaffs_obj *relativeDirectory, const YCHAR *path,int symDepth, int getEquiv)
 {
-       yaffs_obj_t *dir;
-       yaffs_obj_t *obj;
+       struct yaffs_obj *dir;
+       struct yaffs_obj *obj;
        YCHAR *name;
 
        dir = yaffsfs_FindDirectory(relativeDirectory,path,&name,symDepth);
@@ -587,8 +587,8 @@ int yaffs_dup(int fd)
 
 int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int sharing)
 {
-       yaffs_obj_t *obj = NULL;
-       yaffs_obj_t *dir = NULL;
+       struct yaffs_obj *obj = NULL;
+       struct yaffs_obj *dir = NULL;
        YCHAR *name;
        int handle = -1;
        yaffsfs_Handle *yh = NULL;
@@ -596,14 +596,14 @@ int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int sharing)
        int symDepth = 0;
        int errorReported = 0;
        int rwflags = oflag & ( O_RDWR | O_RDONLY | O_WRONLY);
-       __u8 shareRead = (sharing & YAFFS_SHARE_READ) ?  1 : 0;
-       __u8 shareWrite = (sharing & YAFFS_SHARE_WRITE) ? 1 : 0;
-       __u8 sharedReadAllowed;
-       __u8 sharedWriteAllowed;
-       __u8 alreadyReading;
-       __u8 alreadyWriting;
-       __u8 readRequested;
-       __u8 writeRequested;
+       u8 shareRead = (sharing & YAFFS_SHARE_READ) ?  1 : 0;
+       u8 shareWrite = (sharing & YAFFS_SHARE_WRITE) ? 1 : 0;
+       u8 sharedReadAllowed;
+       u8 sharedWriteAllowed;
+       u8 alreadyReading;
+       u8 alreadyWriting;
+       u8 readRequested;
+       u8 writeRequested;
 
        /* O_EXCL only has meaning if O_CREAT is specified */
        if(!(oflag & O_CREAT))
@@ -829,14 +829,14 @@ int yaffs_close(int fd)
 int yaffsfs_do_read(int fd, void *vbuf, unsigned int nbyte, int isPread, int offset)
 {
        yaffsfs_Handle *h = NULL;
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *obj = NULL;
        int pos = 0;
        int startPos = 0;
        int nRead = 0;
        int nToRead = 0;
        int totalRead = 0;
        unsigned int maxRead;
-       __u8 *buf = (__u8 *)vbuf;
+       u8 *buf = (u8 *)vbuf;
 
        yaffsfs_Lock();
        h = yaffsfs_GetHandlePointer(fd);
@@ -925,14 +925,14 @@ int yaffs_pread(int fd, void *buf, unsigned int nbyte, unsigned int offset)
 int yaffsfs_do_write(int fd, const void *vbuf, unsigned int nbyte, int isPwrite, int offset)
 {
        yaffsfs_Handle *h = NULL;
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *obj = NULL;
        int pos = 0;
        int startPos = 0;
        int nWritten = 0;
        int totalWritten = 0;
        int write_trhrough = 0;
        int nToWrite = 0;
-       const __u8 *buf = (const __u8 *)vbuf;
+       const u8 *buf = (const u8 *)vbuf;
 
        yaffsfs_Lock();
        h = yaffsfs_GetHandlePointer(fd);
@@ -1012,7 +1012,7 @@ int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte, unsigned int offse
 
 int yaffs_truncate(const YCHAR *path,off_t new_size)
 {
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *obj = NULL;
        int result = YAFFS_FAIL;
 
        yaffsfs_Lock();
@@ -1037,7 +1037,7 @@ int yaffs_truncate(const YCHAR *path,off_t new_size)
 int yaffs_ftruncate(int fd, off_t new_size)
 {
        yaffsfs_Handle *h = NULL;
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *obj = NULL;
        int result = 0;
 
        yaffsfs_Lock();
@@ -1062,7 +1062,7 @@ int yaffs_ftruncate(int fd, off_t new_size)
 off_t yaffs_lseek(int fd, off_t offset, int whence)
 {
        yaffsfs_Handle *h = NULL;
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *obj = NULL;
        int pos = -1;
        int fSize = -1;
 
@@ -1100,8 +1100,8 @@ off_t yaffs_lseek(int fd, off_t offset, int whence)
 
 int yaffsfs_DoUnlink(const YCHAR *path,int isDirectory)
 {
-       yaffs_obj_t *dir = NULL;
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *dir = NULL;
+       struct yaffs_obj *obj = NULL;
        YCHAR *name;
        int result = YAFFS_FAIL;
 
@@ -1146,9 +1146,9 @@ int yaffs_unlink(const YCHAR *path)
 
 int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
 {
-       yaffs_obj_t *olddir = NULL;
-       yaffs_obj_t *newdir = NULL;
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *olddir = NULL;
+       struct yaffs_obj *newdir = NULL;
+       struct yaffs_obj *obj = NULL;
        YCHAR *oldname;
        YCHAR *newname;
        int result= YAFFS_FAIL;
@@ -1179,7 +1179,7 @@ int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
                 * Do this by tracing from the new directory back to the root, checking for obj
                 */
 
-               yaffs_obj_t *xx = newdir;
+               struct yaffs_obj *xx = newdir;
 
                while( rename_allowed && xx){
                        if(xx == obj)
@@ -1199,7 +1199,7 @@ int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
 }
 
 
-static int yaffsfs_DoStat(yaffs_obj_t *obj,struct yaffs_stat *buf)
+static int yaffsfs_DoStat(struct yaffs_obj *obj,struct yaffs_stat *buf)
 {
        int retVal = -1;
 
@@ -1243,7 +1243,7 @@ static int yaffsfs_DoStat(yaffs_obj_t *obj,struct yaffs_stat *buf)
 
 static int yaffsfs_DoStatOrLStat(const YCHAR *path, struct yaffs_stat *buf,int doLStat)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1278,7 +1278,7 @@ int yaffs_lstat(const YCHAR *path, struct yaffs_stat *buf)
 
 int yaffs_fstat(int fd, struct yaffs_stat *buf)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1302,7 +1302,7 @@ int yaffs_fstat(int fd, struct yaffs_stat *buf)
 
 static int yaffs_do_setxattr(const YCHAR *path, const char *name, const void *data, int size, int flags, int follow)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1343,7 +1343,7 @@ int yaffs_lsetxattr(const YCHAR *path, const char *name, const void *data, int s
 
 int yaffs_fsetxattr(int fd, const char *name, const void *data, int size, int flags)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1367,7 +1367,7 @@ int yaffs_fsetxattr(int fd, const char *name, const void *data, int size, int fl
 
 static int yaffs_do_getxattr(const YCHAR *path, const char *name, void *data, int size, int follow)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1407,7 +1407,7 @@ int yaffs_lgetxattr(const YCHAR *path, const char *name, void *data, int size)
 
 int yaffs_fgetxattr(int fd, const char *name, void *data, int size)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1431,7 +1431,7 @@ int yaffs_fgetxattr(int fd, const char *name, void *data, int size)
 
 static int yaffs_do_listxattr(const YCHAR *path, char *data, int size, int follow)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1470,7 +1470,7 @@ int yaffs_llistxattr(const YCHAR *path, char *data, int size)
 
 int yaffs_flistxattr(int fd, char *data, int size)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1494,7 +1494,7 @@ int yaffs_flistxattr(int fd, char *data, int size)
 
 static int yaffs_do_removexattr(const YCHAR *path, const char *name, int follow)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1533,7 +1533,7 @@ int yaffs_lremovexattr(const YCHAR *path, const char *name)
 
 int yaffs_fremovexattr(int fd, const char *name)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1559,7 +1559,7 @@ int yaffs_fremovexattr(int fd, const char *name)
 #ifdef CONFIG_YAFFS_WINCE
 int yaffs_get_wince_times(int fd, unsigned *wctime, unsigned *watime, unsigned *wmtime)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1598,7 +1598,7 @@ int yaffs_set_wince_times(int fd,
                                                  const unsigned *watime, 
                                                   const unsigned *wmtime)
 {
-        yaffs_obj_t *obj;
+        struct yaffs_obj *obj;
         int result;
         int retVal = -1;
 
@@ -1635,7 +1635,7 @@ int yaffs_set_wince_times(int fd,
 #endif
 
 
-static int yaffsfs_DoChMod(yaffs_obj_t *obj,mode_t mode)
+static int yaffsfs_DoChMod(struct yaffs_obj *obj,mode_t mode)
 {
        int result = -1;
 
@@ -1654,7 +1654,7 @@ static int yaffsfs_DoChMod(yaffs_obj_t *obj,mode_t mode)
 
 int yaffs_access(const YCHAR *path, int amode)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retval = 0;
 
@@ -1691,7 +1691,7 @@ int yaffs_access(const YCHAR *path, int amode)
 
 int yaffs_chmod(const YCHAR *path, mode_t mode)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1715,7 +1715,7 @@ int yaffs_chmod(const YCHAR *path, mode_t mode)
 
 int yaffs_fchmod(int fd, mode_t mode)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        int retVal = -1;
 
@@ -1737,8 +1737,8 @@ int yaffs_fchmod(int fd, mode_t mode)
 
 int yaffs_mkdir(const YCHAR *path, mode_t mode)
 {
-       yaffs_obj_t *parent = NULL;
-       yaffs_obj_t *dir = NULL;
+       struct yaffs_obj *parent = NULL;
+       struct yaffs_obj *dir = NULL;
        YCHAR *name;
        YCHAR *use_path = NULL;
        int path_length = 0;
@@ -1807,7 +1807,7 @@ int yaffs_mkdir(const YCHAR *path, mode_t mode)
 
 void * yaffs_getdev(const YCHAR *path)
 {
-       yaffs_dev_t *dev=NULL;
+       struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
        dev = yaffsfs_FindDevice(path,&dummy);
        return (void *)dev;
@@ -1817,7 +1817,7 @@ int yaffs_mount2(const YCHAR *path,int read_only)
 {
        int retVal=-1;
        int result=YAFFS_FAIL;
-       yaffs_dev_t *dev=NULL;
+       struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
 
        T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: Mounting %s" TENDSTR),path));
@@ -1857,7 +1857,7 @@ int yaffs_mount(const YCHAR *path)
 int yaffs_sync(const YCHAR *path)
 {
         int retVal=-1;
-        yaffs_dev_t *dev=NULL;
+        struct yaffs_dev *dev=NULL;
         YCHAR *dummy;
         
         yaffsfs_Lock();
@@ -1885,7 +1885,7 @@ int yaffs_sync(const YCHAR *path)
 int yaffs_remount(const YCHAR *path, int force, int read_only)
 {
         int retVal=-1;
-       yaffs_dev_t *dev=NULL;
+       struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
 
        yaffsfs_Lock();
@@ -1925,7 +1925,7 @@ int yaffs_remount(const YCHAR *path, int force, int read_only)
 int yaffs_unmount2(const YCHAR *path, int force)
 {
         int retVal=-1;
-       yaffs_dev_t *dev=NULL;
+       struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
 
        yaffsfs_Lock();
@@ -1973,7 +1973,7 @@ int yaffs_unmount(const YCHAR *path)
 loff_t yaffs_freespace(const YCHAR *path)
 {
        loff_t retVal=-1;
-       yaffs_dev_t *dev=NULL;
+       struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
 
        yaffsfs_Lock();
@@ -1992,7 +1992,7 @@ loff_t yaffs_freespace(const YCHAR *path)
 loff_t yaffs_totalspace(const YCHAR *path)
 {
        loff_t retVal=-1;
-       yaffs_dev_t *dev=NULL;
+       struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
 
        yaffsfs_Lock();
@@ -2012,7 +2012,7 @@ loff_t yaffs_totalspace(const YCHAR *path)
 int yaffs_inodecount(const YCHAR *path)
 {
        loff_t retVal= -1;
-       yaffs_dev_t *dev=NULL;
+       struct yaffs_dev *dev=NULL;
        YCHAR *dummy;
 
        yaffsfs_Lock();
@@ -2031,20 +2031,20 @@ int yaffs_inodecount(const YCHAR *path)
 }
 
 
-void yaffs_add_device(yaffs_dev_t *dev)
+void yaffs_add_device(struct yaffs_dev *dev)
 {
        dev->is_mounted = 0;
        dev->param.remove_obj_fn = yaffsfs_RemoveObjectCallback;
 
        if(!dev->dev_list.next)
-               YINIT_LIST_HEAD(&dev->dev_list);
+               INIT_LIST_HEAD(&dev->dev_list);
 
-       ylist_add(&dev->dev_list,&yaffsfs_deviceList);
+       list_add(&dev->dev_list,&yaffsfs_deviceList);
 }
 
-void yaffs_remove_device(yaffs_dev_t *dev)
+void yaffs_remove_device(struct yaffs_dev *dev)
 {
-       ylist_del_init(&dev->dev_list);
+       list_del_init(&dev->dev_list);
 }
 
 
@@ -2061,18 +2061,18 @@ void yaffs_remove_device(yaffs_dev_t *dev)
 
 typedef struct
 {
-       __u32 magic;
+       u32 magic;
        yaffs_dirent de;                /* directory entry being used by this dsc */
        YCHAR name[NAME_MAX+1];         /* name of directory being searched */
-        yaffs_obj_t *dirObj;           /* ptr to directory being searched */
-        yaffs_obj_t *nextReturn;       /* obj to be returned by next readddir */
+        struct yaffs_obj *dirObj;           /* ptr to directory being searched */
+        struct yaffs_obj *nextReturn;       /* obj to be returned by next readddir */
         int offset;
-        struct ylist_head others;       
+        struct list_head others;       
 } yaffsfs_DirectorySearchContext;
 
 
 
-static struct ylist_head search_contexts;
+static struct list_head search_contexts;
 
 
 static void yaffsfs_SetDirRewound(yaffsfs_DirectorySearchContext *dsc)
@@ -2083,11 +2083,11 @@ static void yaffsfs_SetDirRewound(yaffsfs_DirectorySearchContext *dsc)
 
            dsc->offset = 0;
 
-           if( ylist_empty(&dsc->dirObj->variant.dir_variant.children))
+           if( list_empty(&dsc->dirObj->variant.dir_variant.children))
                 dsc->nextReturn = NULL;
            else
-                dsc->nextReturn = ylist_entry(dsc->dirObj->variant.dir_variant.children.next,
-                                                yaffs_obj_t,siblings);
+                dsc->nextReturn = list_entry(dsc->dirObj->variant.dir_variant.children.next,
+                                                struct yaffs_obj,siblings);
         } else {
                /* Hey someone isn't playing nice! */
        }
@@ -2100,25 +2100,25 @@ static void yaffsfs_DirAdvance(yaffsfs_DirectorySearchContext *dsc)
            dsc->dirObj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY){
 
            if( dsc->nextReturn == NULL ||
-               ylist_empty(&dsc->dirObj->variant.dir_variant.children))
+               list_empty(&dsc->dirObj->variant.dir_variant.children))
                 dsc->nextReturn = NULL;
            else {
-                   struct ylist_head *next = dsc->nextReturn->siblings.next;
+                   struct list_head *next = dsc->nextReturn->siblings.next;
 
                    if( next == &dsc->dirObj->variant.dir_variant.children)
                         dsc->nextReturn = NULL; /* end of list */
                    else
-                        dsc->nextReturn = ylist_entry(next,yaffs_obj_t,siblings);
+                        dsc->nextReturn = list_entry(next,struct yaffs_obj,siblings);
            }
         } else {
                 /* Hey someone isn't playing nice! */
        }
 }
 
-static void yaffsfs_RemoveObjectCallback(yaffs_obj_t *obj)
+static void yaffsfs_RemoveObjectCallback(struct yaffs_obj *obj)
 {
 
-        struct ylist_head *i;
+        struct list_head *i;
         yaffsfs_DirectorySearchContext *dsc;
 
         /* if search contexts not initilised then skip */
@@ -2129,9 +2129,9 @@ static void yaffsfs_RemoveObjectCallback(yaffs_obj_t *obj)
          * If any are the one being removed, then advance the dsc to
          * the next one to prevent a hanging ptr.
          */
-         ylist_for_each(i, &search_contexts) {
+         list_for_each(i, &search_contexts) {
                 if (i) {
-                        dsc = ylist_entry(i, yaffsfs_DirectorySearchContext,others);
+                        dsc = list_entry(i, yaffsfs_DirectorySearchContext,others);
                         if(dsc->nextReturn == obj)
                                 yaffsfs_DirAdvance(dsc);
                 }
@@ -2142,7 +2142,7 @@ static void yaffsfs_RemoveObjectCallback(yaffs_obj_t *obj)
 yaffs_DIR *yaffs_opendir(const YCHAR *dirname)
 {
        yaffs_DIR *dir = NULL;
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *obj = NULL;
        yaffsfs_DirectorySearchContext *dsc = NULL;
 
        yaffsfs_Lock();
@@ -2159,12 +2159,12 @@ yaffs_DIR *yaffs_opendir(const YCHAR *dirname)
                         dsc->magic = YAFFS_MAGIC;
                         dsc->dirObj = obj;
                         yaffs_strncpy(dsc->name,dirname,NAME_MAX);
-                        YINIT_LIST_HEAD(&dsc->others);
+                        INIT_LIST_HEAD(&dsc->others);
 
                         if(!search_contexts.next)
-                                YINIT_LIST_HEAD(&search_contexts);
+                                INIT_LIST_HEAD(&search_contexts);
 
-                        ylist_add(&dsc->others,&search_contexts);       
+                        list_add(&dsc->others,&search_contexts);       
                         yaffsfs_SetDirRewound(dsc);
                }
 
@@ -2227,7 +2227,7 @@ int yaffs_closedir(yaffs_DIR *dirp)
 
         yaffsfs_Lock();
         dsc->magic = 0;
-        ylist_del(&dsc->others); /* unhook from list */
+        list_del(&dsc->others); /* unhook from list */
         YFREE(dsc);
         yaffsfs_Unlock();
         return 0;
@@ -2238,8 +2238,8 @@ int yaffs_closedir(yaffs_DIR *dirp)
 
 int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath)
 {
-       yaffs_obj_t *parent = NULL;
-       yaffs_obj_t *obj;
+       struct yaffs_obj *parent = NULL;
+       struct yaffs_obj *obj;
        YCHAR *name;
        int retVal= -1;
        int mode = 0; /* ignore for now */
@@ -2269,7 +2269,7 @@ int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath)
 
 int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz)
 {
-       yaffs_obj_t *obj = NULL;
+       struct yaffs_obj *obj = NULL;
        int retVal;
 
 
@@ -2296,8 +2296,8 @@ int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz)
 int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath)
 {
        /* Creates a link called newpath to existing oldpath */
-       yaffs_obj_t *obj = NULL;
-       yaffs_obj_t *target = NULL;
+       struct yaffs_obj *obj = NULL;
+       struct yaffs_obj *target = NULL;
        int retVal = 0;
        int new_nameLength = 0;
 
@@ -2317,8 +2317,8 @@ int yaffs_link(const YCHAR *oldpath, const YCHAR *newpath)
                yaffsfs_SetError(-EEXIST);
                retVal = -1;
        } else {
-               yaffs_obj_t *newdir = NULL;
-               yaffs_obj_t *link = NULL;
+               struct yaffs_obj *newdir = NULL;
+               struct yaffs_obj *link = NULL;
 
                YCHAR *newname;
 
@@ -2371,7 +2371,7 @@ int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev)
  */
 int yaffs_n_handles(const YCHAR *path)
 {
-       yaffs_obj_t *obj;
+       struct yaffs_obj *obj;
 
        obj = yaffsfs_FindObject(NULL,path,0,1);
 
@@ -2388,10 +2388,10 @@ int yaffs_dump_dev(const YCHAR *path)
 #if 0
        YCHAR *rest;
 
-       yaffs_obj_t *obj = yaffsfs_FindRoot(path,&rest);
+       struct yaffs_obj *obj = yaffsfs_FindRoot(path,&rest);
 
        if(obj){
-               yaffs_dev_t *dev = obj->my_dev;
+               struct yaffs_dev *dev = obj->my_dev;
 
                printf("\n"
                           "n_page_writes.......... %d\n"
index a269ed2..50b5cbc 100644 (file)
@@ -166,8 +166,8 @@ int yaffs_n_handles(const YCHAR *path);
 int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int shareMode) ;
 
 
-struct yaffs_dev_s;
-void yaffs_add_device(struct yaffs_dev_s *dev);
+struct yaffs_dev;
+void yaffs_add_device(struct yaffs_dev *dev);
 
 int yaffs_start_up(void);
 int yaffsfs_GetLastError(void);
index 824ce20..ee6e8f5 100644 (file)
 #define yaffs_sprintf       sprintf
 #define yaffs_toupper(a)     toupper(a)
 
+void yaffs_qsort(void *aa, size_t n, size_t es,
+        int (*cmp)(const void *, const void *));
+
+#define yaffs_sort(base, n, sz, cmp_fn) yaffs_qsort(base, n, sz, cmp_fn)
+        
 #define YAFFS_PATH_DIVIDERS  "/"
 
 #ifdef NO_Y_INLINE
@@ -87,6 +92,9 @@
 #define yaffs_sum_cmp(x,y) ((x) == (y))
 #define yaffs_strcmp(a,b) strcmp(a,b)
 
+#include "yaffs_list.h"
+
+
 #include "yaffsfs.h"
 
 #endif
diff --git a/direct/yportenv.h b/direct/yportenv.h
new file mode 100644 (file)
index 0000000..22afb06
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+
+#ifndef __YPORTENV_H__
+#define __YPORTENV_H__
+
+/*
+ * Define the MTD version in terms of Linux Kernel versions
+ * This allows yaffs to be used independantly of the kernel
+ * as well as with it.
+ */
+
+
+#if defined CONFIG_YAFFS_WINCE
+
+#include "ywinceenv.h"
+
+
+#elif defined CONFIG_YAFFS_DIRECT
+
+/* Direct interface */
+#include "ydirectenv.h"
+
+#elif defined CONFIG_YAFFS_UTIL
+
+/* Stuff for YAFFS utilities */
+
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+
+
+#define YMALLOC(x) malloc(x)
+#define YFREE(x)   free(x)
+#define YMALLOC_ALT(x) malloc(x)
+#define YFREE_ALT(x) free(x)
+
+#define YCHAR char
+#define YUCHAR unsigned char
+#define _Y(x)     x
+#define yaffs_strcat(a, b)     strcat(a, b)
+#define yaffs_strcpy(a, b)     strcpy(a, b)
+#define yaffs_strncpy(a, b, c) strncpy(a, b, c)
+#define yaffs_strnlen(s,m)            strnlen(s,m)
+#define yaffs_sprintf         sprintf
+#define yaffs_toupper(a)       toupper(a)
+
+#define Y_INLINE inline
+
+/* #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) */
+/* #define YALERT(s) YINFO(s) */
+
+#define TENDSTR "\n"
+#define TSTR(x) x
+#define TOUT(p) printf p
+
+#define YAFFS_LOSTNFOUND_NAME          "lost+found"
+#define YAFFS_LOSTNFOUND_PREFIX                "obj"
+/* #define YPRINTF(x) printf x */
+
+#define YAFFS_ROOT_MODE                        0755
+#define YAFFS_LOSTNFOUND_MODE          0700
+
+#define yaffs_sum_cmp(x, y) ((x) == (y))
+#define yaffs_strcmp(a, b) strcmp(a, b)
+
+#else
+/* Should have specified a configuration type */
+#error Unknown configuration
+
+#endif
+
+#if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
+
+#ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
+
+#ifndef O_RDONLY
+#define O_RDONLY        00
+#endif
+
+#ifndef O_WRONLY
+#define O_WRONLY       01
+#endif
+
+#ifndef O_RDWR
+#define O_RDWR         02
+#endif
+
+#ifndef O_CREAT                
+#define O_CREAT        0100
+#endif
+
+#ifndef O_EXCL
+#define O_EXCL         0200
+#endif
+
+#ifndef O_TRUNC
+#define O_TRUNC                01000
+#endif
+
+#ifndef O_APPEND
+#define O_APPEND       02000
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET       0
+#endif
+
+#ifndef SEEK_CUR
+#define SEEK_CUR       1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END       2
+#endif
+
+#ifndef EBUSY
+#define EBUSY  16
+#endif
+
+#ifndef ENODEV
+#define ENODEV 19
+#endif
+
+#ifndef EINVAL
+#define EINVAL 22
+#endif
+
+#ifndef ENFILE
+#define ENFILE 23
+#endif
+
+#ifndef EBADF
+#define EBADF  9
+#endif
+
+#ifndef EACCES
+#define EACCES 13
+#endif
+
+#ifndef EXDEV  
+#define EXDEV  18
+#endif
+
+#ifndef ENOENT
+#define ENOENT 2
+#endif
+
+#ifndef ENOSPC
+#define ENOSPC 28
+#endif
+
+#ifndef ERANGE
+#define ERANGE 34
+#endif
+
+#ifndef ENODATA
+#define ENODATA 61
+#endif
+
+#ifndef ENOTEMPTY
+#define ENOTEMPTY 39
+#endif
+
+#ifndef ENAMETOOLONG
+#define ENAMETOOLONG 36
+#endif
+
+#ifndef ENOMEM
+#define ENOMEM 12
+#endif
+
+#ifndef EEXIST
+#define EEXIST 17
+#endif
+
+#ifndef ENOTDIR
+#define ENOTDIR 20
+#endif
+
+#ifndef EISDIR
+#define EISDIR 21
+#endif
+
+
+// Mode flags
+
+#ifndef S_IFMT
+#define S_IFMT         0170000
+#endif
+
+#ifndef S_IFLNK
+#define S_IFLNK                0120000
+#endif
+
+#ifndef S_IFDIR
+#define S_IFDIR                0040000
+#endif
+
+#ifndef S_IFREG
+#define S_IFREG                0100000
+#endif
+
+#ifndef S_IREAD 
+#define S_IREAD                0000400
+#endif
+
+#ifndef S_IWRITE
+#define        S_IWRITE        0000200
+#endif
+
+#ifndef S_IEXEC
+#define        S_IEXEC 0000100
+#endif
+
+#ifndef XATTR_CREATE
+#define XATTR_CREATE 1
+#endif
+
+#ifndef XATTR_REPLACE
+#define XATTR_REPLACE 2
+#endif
+
+#ifndef R_OK
+#define R_OK   4
+#define W_OK   2
+#define X_OK   1
+#define F_OK   0
+#endif
+
+#else
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#endif
+
+#endif
+
+#ifndef Y_DUMP_STACK
+#define Y_DUMP_STACK() do { } while (0)
+#endif
+
+#ifndef YBUG
+#define YBUG() do {\
+       T(YAFFS_TRACE_BUG,\
+               (TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),\
+               __LINE__));\
+       Y_DUMP_STACK();\
+} while (0)
+#endif
+
+
+#endif
+
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+/*
+ * This file is just holds extra declarations of macros that would normally
+ * be provided in the Linux kernel. These macros have been written from
+ * scratch but are functionally equivalent to the Linux ones.
+ *
+ */
+
+#ifndef __EXTRAS_H__
+#define __EXTRAS_H__
+
+
+/* Definition of types */
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned u32;
+
+
+#ifndef WIN32
+#include <sys/stat.h>
+#endif
+
+
+#ifdef CONFIG_YAFFS_PROVIDE_DEFS
+/* File types */
+
+
+#define DT_UNKNOWN     0
+#define DT_FIFO                1
+#define DT_CHR         2
+#define DT_DIR         4
+#define DT_BLK         6
+#define DT_REG         8
+#define DT_LNK         10
+#define DT_SOCK                12
+#define DT_WHT         14
+
+
+#ifndef WIN32
+#include <sys/stat.h>
+#endif
+
+/*
+ * Attribute flags.  These should be or-ed together to figure out what
+ * has been changed!
+ */
+#define ATTR_MODE      1
+#define ATTR_UID       2
+#define ATTR_GID       4
+#define ATTR_SIZE      8
+#define ATTR_ATIME     16
+#define ATTR_MTIME     32
+#define ATTR_CTIME     64
+
+struct iattr {
+       unsigned int ia_valid;
+       unsigned ia_mode;
+       unsigned ia_uid;
+       unsigned ia_gid;
+       unsigned ia_size;
+       unsigned ia_atime;
+       unsigned ia_mtime;
+       unsigned ia_ctime;
+       unsigned int ia_attr_flags;
+};
+
+#endif
+
+
+
+#endif
index 4b4d642..20a0882 100644 (file)
@@ -62,7 +62,6 @@
 /* Meaning: Select to disable background processing */
 /* #define CONFIG_DISABLE_BACKGROUND */
 
-
 /* Default: Selected */
 /* Meaning: Enable XATTR support */
 #define CONFIG_YAFFS_XATTR
index 862b244..4cba57b 100644 (file)
@@ -66,7 +66,7 @@ static struct mtd_info nandemul2k_mtd;
 
 typedef struct 
 {
-       __u8 data[PAGE_TOTAL_SIZE]; // Data + spare
+       u8 data[PAGE_TOTAL_SIZE]; // Data + spare
        int empty;      // is this empty?
 } nandemul_Page;
 
@@ -114,8 +114,8 @@ static void nandemul2k_Program(const void *buffer, int page, int start, int n_by
 {
        int pg = page%PAGES_PER_BLOCK;
        int blk = page/PAGES_PER_BLOCK;
-       __u8 *p;
-       __u8 *b = (__u8 *)buffer;
+       u8 *p;
+       u8 *b = (u8 *)buffer;
 
        p = &ned.block[blk]->page[pg]->data[start];
        
@@ -255,7 +255,7 @@ int nandemul2k_GetNumberOfBlocks(void) {return nandemul2k_CalcNBlocks();}
 
 
 
-static int nandemul2k_ReadId(__u8 *vendorId, __u8 *deviceId)
+static int nandemul2k_ReadId(u8 *vendorId, u8 *deviceId)
 {
        *vendorId = 'Y'; 
        *deviceId = '2';
@@ -264,7 +264,7 @@ static int nandemul2k_ReadId(__u8 *vendorId, __u8 *deviceId)
 }
 
 
-static int nandemul2k_ReadStatus(__u8 *status)
+static int nandemul2k_ReadStatus(u8 *status)
 {
                *status = 0;
                return 1;
index 5894087..ba6b6e4 100755 (executable)
@@ -53,9 +53,16 @@ else
 fi
 
 if [ $MULTIORSINGLE = m ]; then
-   VFSGLUE="yaffs_vfs_multi.c"
+   VFS_CODE="yaffs_vfs_multi.c"
+   MTD1_CODE="yaffs_mtdif1_multi.c"
+   MTD2_CODE="yaffs_mtdif2_multi.c"
+   YPORTENV="yportenv_multi.h"
 elif [ $MULTIORSINGLE = s ]; then
-   VFSGLUE="yaffs_vfs.c"
+   VFS_CODE="yaffs_vfs_single.c"
+   MTD1_CODE="yaffs_mtdif1_single.c"
+   MTD2_CODE="yaffs_mtdif2_single.c"
+   YPORTENV="yportenv_single.h"
+
    echo ""
    echo "*** Warning ***"
    echo "You have chosen to use the single kernel variant of the yaffs VFS glue code"
@@ -112,17 +119,17 @@ else
     echo "Updating $KCONFIG"
     mv -f $KCONFIG  $KCONFIGOLD
     sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 ! p" $KCONFIGOLD >$KCONFIG
-    echo "">>$KCONFIG
-    echo "# Patched by YAFFS" >>$KCONFIG
+    echo "">>$KCONFIG
+    echo "# Patched by YAFFS" >>$KCONFIG
     echo "source \"fs/yaffs2/Kconfig\"">>$KCONFIG
-    echo "">>$KCONFIG
+    echo "">>$KCONFIG
     sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 p" $KCONFIGOLD >>$KCONFIG
 
    # now do fs/Makefile -- simply add the target at the end
     echo "Updating $MAKEFILE"
     cp -f $MAKEFILE $MAKEFILEOLD
-    echo "">>$MAKEFILE
-    echo "# Patched by YAFFS" >>$MAKEFILE
+    echo "">>$MAKEFILE
+    echo "# Patched by YAFFS" >>$MAKEFILE
     echo "obj-\$(CONFIG_YAFFS_FS)              += yaffs2/" >>$MAKEFILE
 
 fi
@@ -135,10 +142,16 @@ then
    echo "already there then delete $YAFFSDIR and re-run this script"
    echo " eg.  \"rm -rf $YAFFSDIR\" "
 else
+   rm yaffs*.mod.c
    mkdir $LINUXDIR/fs/yaffs2
    $CPY  $PWD/Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile
    $CPY $PWD/Kconfig $LINUXDIR/fs/yaffs2
    $CPY $PWD/*.c $PWD/*.h  $LINUXDIR/fs/yaffs2
-   rm $LINUXDIR/fs/yaffs2/yaffs_vfs.c $LINUXDIR/fs/yaffs2/yaffs_vfs_multi.c
-   $CPY $PWD/$VFSGLUE $LINUXDIR/fs/yaffs2/yaffs_vfs_glue.c
+   rm $LINUXDIR/fs/yaffs2/yaffs_vfs*.c $LINUXDIR/fs/yaffs2/yaffs_mtdif[12]*.c
+   rm $LINUXDIR/fs/yaffs2/yportenv*.h
+   rm $LINUXDIR/fs/yaffs2/moduleconfig.h
+   $CPY $PWD/$VFS_CODE $LINUXDIR/fs/yaffs2/yaffs_vfs.c
+   $CPY $PWD/$MTD1_CODE $LINUXDIR/fs/yaffs2/yaffs_mtdif1.c
+   $CPY $PWD/$MTD2_CODE $LINUXDIR/fs/yaffs2/yaffs_mtdif2.c
+   $CPY $PWD/$YPORTENV $LINUXDIR/fs/yaffs2/yportenv.h
 fi
similarity index 90%
rename from yaffs_linux_allocator.c
rename to patches/yaffs_linux_allocator.c
index d0837f8..b538776 100644 (file)
@@ -42,7 +42,7 @@ typedef struct yaffs_AllocatorStruct yaffs_Allocator;
 
 int mount_id;
 
-void yaffs_deinit_raw_tnodes_and_objs(yaffs_dev_t *dev)
+void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev)
 {
        yaffs_Allocator *allocator = (yaffs_Allocator *)dev->allocator;
 
@@ -102,10 +102,10 @@ static void (*fake_ctor_list[10]) (void *) = {
        fake_ctor9,
 };
 
-void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev)
+void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev)
 {
        yaffs_Allocator *allocator;
-       unsigned mount_id = yaffs_dev_to_lc(dev)->mount_id;
+       unsigned mount_id = struct yaffs_devo_lc(dev)->mount_id;
 
        T(YAFFS_TRACE_ALLOCATE,(TSTR("Initialising yaffs allocator\n")));
 
@@ -147,7 +147,7 @@ void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev)
 
                allocator->object_cache = 
                        kmem_cache_create(allocator->object_name,
-                               sizeof(yaffs_obj_t),
+                               sizeof(struct yaffs_obj),
                                0, 0,
                                fake_ctor_list[mount_id]);
 
@@ -165,7 +165,7 @@ void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev)
 }
 
 
-yaffs_tnode_t *yaffs_alloc_raw_tnode(yaffs_dev_t *dev)
+struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev)
 {
        yaffs_Allocator *allocator = dev->allocator;
        if(!allocator || !allocator->tnode_cache){
@@ -175,13 +175,13 @@ yaffs_tnode_t *yaffs_alloc_raw_tnode(yaffs_dev_t *dev)
        return kmem_cache_alloc(allocator->tnode_cache, GFP_NOFS);
 }
 
-void yaffs_free_raw_tnode(yaffs_dev_t *dev, yaffs_tnode_t *tn)
+void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn)
 {
        yaffs_Allocator *allocator = dev->allocator;
        kmem_cache_free(allocator->tnode_cache,tn);
 }
 
-yaffs_obj_t *yaffs_alloc_raw_obj(yaffs_dev_t *dev)
+struct yaffs_obj *yaffs_alloc_raw_obj(struct yaffs_dev *dev)
 {
        yaffs_Allocator *allocator = dev->allocator;
        if(!allocator){
@@ -195,7 +195,7 @@ yaffs_obj_t *yaffs_alloc_raw_obj(yaffs_dev_t *dev)
        return kmem_cache_alloc(allocator->object_cache, GFP_NOFS);
 }
 
-void yaffs_free_raw_obj(yaffs_dev_t *dev, yaffs_obj_t *obj)
+void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj)
 {
        yaffs_Allocator *allocator = dev->allocator;
        kmem_cache_free(allocator->object_cache,obj);
index c105e45..19677ad 100644 (file)
@@ -28,10 +28,10 @@ const char *yaffs_mtdif2_c_version =
 #include "yaffs_packedtags2.h"
 
 
-void nandmtd2_pt2buf(yaffs_dev_t *dev, yaffs_PackedTags2 *pt, int is_raw)
+void nandmtd2_pt2buf(struct yaffs_dev *dev, yaffs_PackedTags2 *pt, int is_raw)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-       __u8 *ptab = (__u8 *)pt; /* packed tags as bytes */
+       u8 *ptab = (u8 *)pt; /* packed tags as bytes */
        
        int     i, j = 0, k, n;
 
@@ -69,11 +69,11 @@ void nandmtd2_pt2buf(yaffs_dev_t *dev, yaffs_PackedTags2 *pt, int is_raw)
 
 }
 
-void nandmtd2_buf2pt(yaffs_dev_t *dev, yaffs_PackedTags2 *pt, int is_raw)
+void nandmtd2_buf2pt(struct yaffs_dev *dev, yaffs_PackedTags2 *pt, int is_raw)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
        int     i, j = 0, k, n;
-       __u8 *ptab = (__u8 *)pt; /* packed tags as bytes */
+       u8 *ptab = (u8 *)pt; /* packed tags as bytes */
 
 
        if (!is_raw) {
@@ -107,9 +107,9 @@ void nandmtd2_buf2pt(yaffs_dev_t *dev, yaffs_PackedTags2 *pt, int is_raw)
                
 }
 
-int nandmtd2_WriteChunkWithTagsToNAND(yaffs_dev_t * dev, int nand_chunk,
-                                     const __u8 * data,
-                                     const yaffs_ext_tags * tags)
+int nandmtd2_WriteChunkWithTagsToNAND(struct yaffs_dev * dev, int nand_chunk,
+                                     const u8 * data,
+                                     const struct yaffs_ext_tags * tags)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
        size_t dummy;
@@ -149,8 +149,8 @@ int nandmtd2_WriteChunkWithTagsToNAND(yaffs_dev_t * dev, int nand_chunk,
                return YAFFS_FAIL;
 }
 
-int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_dev_t * dev, int nand_chunk,
-                                      __u8 * data, yaffs_ext_tags * tags)
+int nandmtd2_ReadChunkWithTagsFromNAND(struct yaffs_dev * dev, int nand_chunk,
+                                      u8 * data, struct yaffs_ext_tags * tags)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
        size_t dummy;
@@ -193,7 +193,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_dev_t * dev, int nand_chunk,
                return YAFFS_FAIL;
 }
 
-int nandmtd2_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no)
+int nandmtd2_MarkNANDBlockBad(struct yaffs_dev *dev, int block_no)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
        int retval;
@@ -212,8 +212,8 @@ int nandmtd2_MarkNANDBlockBad(struct yaffs_dev_s *dev, int block_no)
 
 }
 
-int nandmtd2_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no,
-                           yaffs_block_state_t * state, int *seq_number)
+int nandmtd2_QueryNANDBlock(struct yaffs_dev *dev, int block_no,
+                           enum yaffs_block_state * state, int *seq_number)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
        int retval;
@@ -231,7 +231,7 @@ int nandmtd2_QueryNANDBlock(struct yaffs_dev_s *dev, int block_no,
                *state = YAFFS_BLOCK_STATE_DEAD;
                *seq_number = 0;
        } else {
-               yaffs_ext_tags t;
+               struct yaffs_ext_tags t;
                nandmtd2_ReadChunkWithTagsFromNAND(dev,
                                                   block_no *
                                                   dev->chunks_per_block, NULL,
index 2d63908..fa2229b 100644 (file)
@@ -143,11 +143,11 @@ static int find_obj_in_list(dev_t dev, ino_t ino)
  * NOTE: The tag is not usable after this other than calculating the CRC
  * with.
  */
-static void little_to_big_endian(yaffs_ext_tags *tagsPtr)
+static void little_to_big_endian(struct yaffs_ext_tags *tagsPtr)
 {
 #if 0 // FIXME NCB
-    yaffs_tags_union_t * tags = (yaffs_tags_union_t* )tagsPtr; // Work in bytes.
-    yaffs_tags_union_t   temp;
+    union yaffs_tags_union * tags = (union yaffs_tags_union* )tagsPtr; // Work in bytes.
+    union yaffs_tags_union   temp;
 
     memset(&temp, 0, sizeof(temp));
     // Ick, I hate magic numbers.
@@ -172,17 +172,17 @@ static void little_to_big_endian(yaffs_ext_tags *tagsPtr)
 #endif
 }
 
-static void shuffle_oob(char *spareData, yaffs_packed_tags2 *pt)
+static void shuffle_oob(char *spareData, struct yaffs_packed_tags2 *pt)
 {
        assert(sizeof(*pt) <= spareSize);
        // NAND LAYOUT: For non-trivial OOB orderings, here would be a good place to shuffle.
        memcpy(spareData, pt, sizeof(*pt));
 }
 
-static int write_chunk(__u8 *data, __u32 id, __u32 chunk_id, __u32 n_bytes)
+static int write_chunk(u8 *data, u32 id, u32 chunk_id, u32 n_bytes)
 {
-       yaffs_ext_tags t;
-       yaffs_packed_tags2 pt;
+       struct yaffs_ext_tags t;
+       struct yaffs_packed_tags2 pt;
        char spareData[spareSize];
 
        if (write(outFile,data,chunkSize) != chunkSize)
@@ -228,12 +228,12 @@ static int write_chunk(__u8 *data, __u32 id, __u32 chunk_id, __u32 n_bytes)
                      (((x) & 0xFF00) >> 8))
         
 // This one is easier, since the types are more standard. No funky shifts here.
-static void object_header_little_to_big_endian(yaffs_obj_header* oh)
+static void object_header_little_to_big_endian(struct yaffs_obj_hdr* oh)
 {
     int i;    
     oh->type = SWAP32(oh->type); // GCC makes enums 32 bits.
     oh->parent_obj_id = SWAP32(oh->parent_obj_id); // int
-    oh->sum_no_longer_used = SWAP16(oh->sum_no_longer_used); // __u16 - Not used, but done for completeness.
+    oh->sum_no_longer_used = SWAP16(oh->sum_no_longer_used); // u16 - Not used, but done for completeness.
     // name = skip. Char array. Not swapped.
     oh->yst_mode = SWAP32(oh->yst_mode);
 #ifdef CONFIG_YAFFS_WINCE // WinCE doesn't implement this, but we need to just in case. 
@@ -276,12 +276,12 @@ static void object_header_little_to_big_endian(yaffs_obj_header* oh)
 #endif
 }
 
-static int write_object_header(int id, yaffs_obj_type t, struct stat *s, int parent, const char *name, int equivalentObj, const char * alias)
+static int write_object_header(int id, enum yaffs_obj_type t, struct stat *s, int parent, const char *name, int equivalentObj, const char * alias)
 {
-       __u8 bytes[chunkSize];
+       u8 bytes[chunkSize];
        
        
-       yaffs_obj_header *oh = (yaffs_obj_header *)bytes;
+       struct yaffs_obj_hdr *oh = (struct yaffs_obj_hdr *)bytes;
        
        memset(bytes,0xff,sizeof(bytes));
        
@@ -342,7 +342,7 @@ static int write_object_header(int id, yaffs_obj_type t, struct stat *s, int par
 
 static void pad_image(void)
 {
-       __u8 data[chunkSize + spareSize];
+       u8 data[chunkSize + spareSize];
        int padPages = (nPages % pagesPerBlock);
 
        if (padPages)
@@ -444,7 +444,7 @@ static int process_directory(int parent, const char *path)
                                                        if(write_object_header(newObj, YAFFS_OBJECT_TYPE_FILE, &stats, parent, entry->d_name, -1, NULL) == 0)
                                                        {
                                                                int h;
-                                                               __u8 bytes[chunkSize];
+                                                               u8 bytes[chunkSize];
                                                                int n_bytes;
                                                                int chunk = 0;
                                                                
index 94b0298..02ad521 100644 (file)
@@ -113,12 +113,12 @@ static int find_obj_in_list(dev_t dev, ino_t ino)
 }
 
 // NCB added 10/9/2002
-static __u16 yaffs_calc_name_sum(const char *name)
+static u16 yaffs_calc_name_sum(const char *name)
 {
-       __u16 sum = 0;
-       __u16 i = 1;
+       u16 sum = 0;
+       u16 i = 1;
        
-       __u8 *bname = (__u8 *)name;
+       u8 *bname = (u8 *)name;
        
        while (*bname)
        {
@@ -130,16 +130,16 @@ static __u16 yaffs_calc_name_sum(const char *name)
 }
 
 
-static void yaffs_calc_ecc(const __u8 *data, yaffs_spare *spare)
+static void yaffs_calc_ecc(const u8 *data, struct yaffs_spare *spare)
 {
        yaffs_ecc_cacl(data , spare->ecc1);
        yaffs_ecc_cacl(&data[256] , spare->ecc2);
 }
 
-static void yaffs_calc_tags_ecc(yaffs_tags_t *tags)
+static void yaffs_calc_tags_ecc(struct yaffs_tags *tags)
 {
        // Todo don't do anything yet. Need to calculate ecc
-       unsigned char *b = ((yaffs_tags_union_t *)tags)->as_bytes;
+       unsigned char *b = ((union yaffs_tags_union *)tags)->as_bytes;
        unsigned  i,j;
        unsigned  ecc = 0;
        unsigned bit = 0;
@@ -181,9 +181,9 @@ static void yaffs_calc_tags_ecc(yaffs_tags_t *tags)
         b[7] |= ((ecc & 0x3F) << 2);
     }
 }
-static void yaffs_load_tags_to_spare(yaffs_spare *sparePtr, yaffs_tags_t *tagsPtr)
+static void yaffs_load_tags_to_spare(struct yaffs_spare *sparePtr, struct yaffs_tags *tagsPtr)
 {
-       yaffs_tags_union_t *tu = (yaffs_tags_union_t *)tagsPtr;
+       union yaffs_tags_union *tu = (union yaffs_tags_union *)tagsPtr;
        
        //yaffs_calc_tags_ecc(tagsPtr);
        
@@ -201,10 +201,10 @@ static void yaffs_load_tags_to_spare(yaffs_spare *sparePtr, yaffs_tags_t *tagsPt
  * NOTE: The tag is not usable after this other than calculating the CRC
  * with.
  */
-static void little_to_big_endian(yaffs_tags_t *tagsPtr)
+static void little_to_big_endian(struct yaffs_tags *tagsPtr)
 {
-    yaffs_tags_union_t * tags = (yaffs_tags_union_t* )tagsPtr; // Work in bytes.
-    yaffs_tags_union_t   temp;
+    union yaffs_tags_union * tags = (union yaffs_tags_union* )tagsPtr; // Work in bytes.
+    union yaffs_tags_union   temp;
 
     memset(&temp, 0, sizeof(temp));
     // Ick, I hate magic numbers.
@@ -228,16 +228,16 @@ static void little_to_big_endian(yaffs_tags_t *tagsPtr)
     tags->as_bytes[7] = temp.as_bytes[7];
 }
 
-static int write_chunk(__u8 *data, __u32 obj_id, __u32 chunk_id, __u32 n_bytes)
+static int write_chunk(u8 *data, u32 obj_id, u32 chunk_id, u32 n_bytes)
 {
-       yaffs_tags_t t;
-       yaffs_spare s;
+       struct yaffs_tags t;
+       struct yaffs_spare s;
 
        error = write(outFile,data,512);
        if(error < 0) return error;
 
-       memset(&t,0xff,sizeof (yaffs_tags_t));
-       memset(&s,0xff,sizeof (yaffs_spare));
+       memset(&t,0xff,sizeof (struct yaffs_tags));
+       memset(&s,0xff,sizeof (struct yaffs_spare));
        
        t.chunk_id = chunk_id;
        t.serial_number = 0;
@@ -255,7 +255,7 @@ static int write_chunk(__u8 *data, __u32 obj_id, __u32 chunk_id, __u32 n_bytes)
        
        nPages++;
        
-       return write(outFile,&s,sizeof(yaffs_spare));
+       return write(outFile,&s,sizeof(struct yaffs_spare));
        
 }
 
@@ -268,11 +268,11 @@ static int write_chunk(__u8 *data, __u32 obj_id, __u32 chunk_id, __u32 n_bytes)
                      (((x) & 0xFF00) >> 8))
         
 // This one is easier, since the types are more standard. No funky shifts here.
-static void object_header_little_to_big_endian(yaffs_obj_header* oh)
+static void object_header_little_to_big_endian(struct yaffs_obj_hdr* oh)
 {
     oh->type = SWAP32(oh->type); // GCC makes enums 32 bits.
     oh->parent_obj_id = SWAP32(oh->parent_obj_id); // int
-    oh->sum_no_longer_used = SWAP16(oh->sum_no_longer_used); // __u16 - Not used, but done for completeness.
+    oh->sum_no_longer_used = SWAP16(oh->sum_no_longer_used); // u16 - Not used, but done for completeness.
     // name = skip. Char array. Not swapped.
     oh->yst_mode = SWAP32(oh->yst_mode);
 #ifdef CONFIG_YAFFS_WINCE // WinCE doesn't implement this, but we need to just in case. 
@@ -325,12 +325,12 @@ static void object_header_little_to_big_endian(yaffs_obj_header* oh)
 #endif
 }
 
-static int write_object_header(int obj_id, yaffs_obj_type t, struct stat *s, int parent, const char *name, int equivalentObj, const char * alias)
+static int write_object_header(int obj_id, enum yaffs_obj_type t, struct stat *s, int parent, const char *name, int equivalentObj, const char * alias)
 {
-       __u8 bytes[512];
+       u8 bytes[512];
        
        
-       yaffs_obj_header *oh = (yaffs_obj_header *)bytes;
+       struct yaffs_obj_hdr *oh = (struct yaffs_obj_hdr *)bytes;
        
        memset(bytes,0xff,512);
        
@@ -453,7 +453,7 @@ static int process_directory(int parent, const char *path)
                                                        if(error >= 0)
                                                        {
                                                                int h;
-                                                               __u8 bytes[512];
+                                                               u8 bytes[512];
                                                                int n_bytes;
                                                                int chunk = 0;
                                                                
index 024ee2a..03ede86 100644 (file)
@@ -11,8 +11,6 @@
  * published by the Free Software Foundation.
  */
 
-
-
 #include "yaffs_allocator.h"
 #include "yaffs_guts.h"
 #include "yaffs_trace.h"
 
 #ifdef CONFIG_YAFFS_YMALLOC_ALLOCATOR
 
-void yaffs_deinit_raw_tnodes_and_objs(yaffs_dev_t *dev)
+void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev)
 {
        dev = dev;
 }
 
-void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev)
+void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev)
 {
        dev = dev;
 }
 
-yaffs_tnode_t *yaffs_alloc_raw_tnode(yaffs_dev_t *dev)
+struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev)
 {
-       return (yaffs_tnode_t *)YMALLOC(dev->tnode_size);
+       return (struct yaffs_tnode *)YMALLOC(dev->tnode_size);
 }
 
-void yaffs_free_raw_tnode(yaffs_dev_t *dev, yaffs_tnode_t *tn)
+void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn)
 {
        dev = dev;
        YFREE(tn);
 }
 
-void yaffs_init_raw_objs(yaffs_dev_t *dev)
+void yaffs_init_raw_objs(struct yaffs_dev *dev)
 {
        dev = dev;
 }
 
-void yaffs_deinit_raw_objs(yaffs_dev_t *dev)
+void yaffs_deinit_raw_objs(struct yaffs_dev *dev)
 {
        dev = dev;
 }
 
-yaffs_obj_t *yaffs_alloc_raw_obj(yaffs_dev_t *dev)
+struct yaffs_obj *yaffs_alloc_raw_obj(struct yaffs_dev *dev)
 {
        dev = dev;
-       return (yaffs_obj_t *) YMALLOC(sizeof(yaffs_obj_t));
+       return (struct yaffs_obj *)YMALLOC(sizeof(struct yaffs_obj));
 }
 
-
-void yaffs_free_raw_obj(yaffs_dev_t *dev, yaffs_obj_t *obj)
+void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj)
 {
 
        dev = dev;
@@ -69,85 +66,79 @@ void yaffs_free_raw_obj(yaffs_dev_t *dev, yaffs_obj_t *obj)
 
 struct yaffs_tnode_list {
        struct yaffs_tnode_list *next;
-       yaffs_tnode_t *tnodes;
+       struct yaffs_tnode *tnodes;
 };
 
-typedef struct yaffs_tnode_list yaffs_tnodelist_t;
-
-struct yaffs_obj_list_struct {
-       yaffs_obj_t *objects;
-       struct yaffs_obj_list_struct *next;
+struct yaffs_obj_list {
+       struct yaffs_obj_list *next;
+       struct yaffs_obj *objects;
 };
 
-typedef struct yaffs_obj_list_struct yaffs_obj_list;
+struct yaffs_allocator {
+       int n_tnodes_created;
+       struct yaffs_tnode *free_tnodes;
+       int n_free_tnodes;
+       struct yaffs_tnode_list *alloc_tnode_list;
 
+       int n_obj_created;
+       struct yaffs_obj *free_objs;
+       int n_free_objects;
 
-struct yaffs_AllocatorStruct {
-       int n_tnodesCreated;
-       yaffs_tnode_t *freeTnodes;
-       int nFreeTnodes;
-       yaffs_tnodelist_t *allocatedTnodeList;
-
-       int n_objCreated;
-       yaffs_obj_t *freeObjects;
-       int nFreeObjects;
-
-       yaffs_obj_list *allocated_list;
+       struct yaffs_obj_list *allocated_obj_list;
 };
 
-typedef struct yaffs_AllocatorStruct yaffs_Allocator;
-
-
-static void yaffs_deinit_raw_tnodes(yaffs_dev_t *dev)
+static void yaffs_deinit_raw_tnodes(struct yaffs_dev *dev)
 {
 
-       yaffs_Allocator *allocator = (yaffs_Allocator *)dev->allocator;
+       struct yaffs_allocator *allocator =
+           (struct yaffs_allocator *)dev->allocator;
 
-       yaffs_tnodelist_t *tmp;
+       struct yaffs_tnode_list *tmp;
 
-       if(!allocator){
+       if (!allocator) {
                YBUG();
                return;
        }
 
-       while (allocator->allocatedTnodeList) {
-               tmp = allocator->allocatedTnodeList->next;
+       while (allocator->alloc_tnode_list) {
+               tmp = allocator->alloc_tnode_list->next;
 
-               YFREE(allocator->allocatedTnodeList->tnodes);
-               YFREE(allocator->allocatedTnodeList);
-               allocator->allocatedTnodeList = tmp;
+               YFREE(allocator->alloc_tnode_list->tnodes);
+               YFREE(allocator->alloc_tnode_list);
+               allocator->alloc_tnode_list = tmp;
 
        }
 
-       allocator->freeTnodes = NULL;
-       allocator->nFreeTnodes = 0;
-       allocator->n_tnodesCreated = 0;
+       allocator->free_tnodes = NULL;
+       allocator->n_free_tnodes = 0;
+       allocator->n_tnodes_created = 0;
 }
 
-static void yaffs_init_raw_tnodes(yaffs_dev_t *dev)
+static void yaffs_init_raw_tnodes(struct yaffs_dev *dev)
 {
-       yaffs_Allocator *allocator = dev->allocator;
+       struct yaffs_allocator *allocator = dev->allocator;
 
-       if(allocator){
-               allocator->allocatedTnodeList = NULL;
-               allocator->freeTnodes = NULL;
-               allocator->nFreeTnodes = 0;
-               allocator->n_tnodesCreated = 0;
+       if (allocator) {
+               allocator->alloc_tnode_list = NULL;
+               allocator->free_tnodes = NULL;
+               allocator->n_free_tnodes = 0;
+               allocator->n_tnodes_created = 0;
        } else
                YBUG();
 }
 
-static int yaffs_create_tnodes(yaffs_dev_t *dev, int n_tnodes)
+static int yaffs_create_tnodes(struct yaffs_dev *dev, int n_tnodes)
 {
-       yaffs_Allocator *allocator = (yaffs_Allocator *)dev->allocator;
+       struct yaffs_allocator *allocator =
+           (struct yaffs_allocator *)dev->allocator;
        int i;
-       yaffs_tnode_t *newTnodes;
-       __u8 *mem;
-       yaffs_tnode_t *curr;
-       yaffs_tnode_t *next;
-       yaffs_tnodelist_t *tnl;
+       struct yaffs_tnode *new_tnodes;
+       u8 *mem;
+       struct yaffs_tnode *curr;
+       struct yaffs_tnode *next;
+       struct yaffs_tnode_list *tnl;
 
-       if(!allocator){
+       if (!allocator) {
                YBUG();
                return YAFFS_FAIL;
        }
@@ -155,47 +146,46 @@ static int yaffs_create_tnodes(yaffs_dev_t *dev, int n_tnodes)
        if (n_tnodes < 1)
                return YAFFS_OK;
 
-
        /* make these things */
 
-       newTnodes = YMALLOC(n_tnodes * dev->tnode_size);
-       mem = (__u8 *)newTnodes;
+       new_tnodes = YMALLOC(n_tnodes * dev->tnode_size);
+       mem = (u8 *) new_tnodes;
 
-       if (!newTnodes) {
+       if (!new_tnodes) {
                T(YAFFS_TRACE_ERROR,
-                       (TSTR("yaffs: Could not allocate Tnodes" TENDSTR)));
+                 (TSTR("yaffs: Could not allocate Tnodes" TENDSTR)));
                return YAFFS_FAIL;
        }
 
        /* New hookup for wide tnodes */
        for (i = 0; i < n_tnodes - 1; i++) {
-               curr = (yaffs_tnode_t *) &mem[i * dev->tnode_size];
-               next = (yaffs_tnode_t *) &mem[(i+1) * dev->tnode_size];
+               curr = (struct yaffs_tnode *)&mem[i * dev->tnode_size];
+               next = (struct yaffs_tnode *)&mem[(i + 1) * dev->tnode_size];
                curr->internal[0] = next;
        }
 
-       curr = (yaffs_tnode_t *) &mem[(n_tnodes - 1) * dev->tnode_size];
-       curr->internal[0] = allocator->freeTnodes;
-       allocator->freeTnodes = (yaffs_tnode_t *)mem;
+       curr = (struct yaffs_tnode *)&mem[(n_tnodes - 1) * dev->tnode_size];
+       curr->internal[0] = allocator->free_tnodes;
+       allocator->free_tnodes = (struct yaffs_tnode *)mem;
 
-       allocator->nFreeTnodes += n_tnodes;
-       allocator->n_tnodesCreated += n_tnodes;
+       allocator->n_free_tnodes += n_tnodes;
+       allocator->n_tnodes_created += n_tnodes;
 
        /* Now add this bunch of tnodes to a list for freeing up.
         * NB If we can't add this to the management list it isn't fatal
         * but it just means we can't free this bunch of tnodes later.
         */
 
-       tnl = YMALLOC(sizeof(yaffs_tnodelist_t));
+       tnl = YMALLOC(sizeof(struct yaffs_tnode_list));
        if (!tnl) {
                T(YAFFS_TRACE_ERROR,
                  (TSTR
                   ("yaffs: Could not add tnodes to management list" TENDSTR)));
-                  return YAFFS_FAIL;
+               return YAFFS_FAIL;
        } else {
-               tnl->tnodes = newTnodes;
-               tnl->next = allocator->allocatedTnodeList;
-               allocator->allocatedTnodeList = tnl;
+               tnl->tnodes = new_tnodes;
+               tnl->next = allocator->alloc_tnode_list;
+               allocator->alloc_tnode_list = tnl;
        }
 
        T(YAFFS_TRACE_ALLOCATE, (TSTR("yaffs: Tnodes added" TENDSTR)));
@@ -203,95 +193,92 @@ static int yaffs_create_tnodes(yaffs_dev_t *dev, int n_tnodes)
        return YAFFS_OK;
 }
 
-
-yaffs_tnode_t *yaffs_alloc_raw_tnode(yaffs_dev_t *dev)
+struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev)
 {
-       yaffs_Allocator *allocator = (yaffs_Allocator *)dev->allocator;
-       yaffs_tnode_t *tn = NULL;
+       struct yaffs_allocator *allocator =
+           (struct yaffs_allocator *)dev->allocator;
+       struct yaffs_tnode *tn = NULL;
 
-       if(!allocator){
+       if (!allocator) {
                YBUG();
                return NULL;
        }
 
        /* If there are none left make more */
-       if (!allocator->freeTnodes)
+       if (!allocator->free_tnodes)
                yaffs_create_tnodes(dev, YAFFS_ALLOCATION_NTNODES);
 
-       if (allocator->freeTnodes) {
-               tn = allocator->freeTnodes;
-               allocator->freeTnodes = allocator->freeTnodes->internal[0];
-               allocator->nFreeTnodes--;
+       if (allocator->free_tnodes) {
+               tn = allocator->free_tnodes;
+               allocator->free_tnodes = allocator->free_tnodes->internal[0];
+               allocator->n_free_tnodes--;
        }
 
        return tn;
 }
 
 /* FreeTnode frees up a tnode and puts it back on the free list */
-void yaffs_free_raw_tnode(yaffs_dev_t *dev, yaffs_tnode_t *tn)
+void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn)
 {
-       yaffs_Allocator *allocator = dev->allocator;
+       struct yaffs_allocator *allocator = dev->allocator;
 
-       if(!allocator){
+       if (!allocator) {
                YBUG();
                return;
        }
 
        if (tn) {
-               tn->internal[0] = allocator->freeTnodes;
-               allocator->freeTnodes = tn;
-               allocator->nFreeTnodes++;
+               tn->internal[0] = allocator->free_tnodes;
+               allocator->free_tnodes = tn;
+               allocator->n_free_tnodes++;
        }
-       dev->checkpoint_blocks_required = 0; /* force recalculation*/
+       dev->checkpoint_blocks_required = 0;    /* force recalculation */
 }
 
-
-
-static void yaffs_init_raw_objs(yaffs_dev_t *dev)
+static void yaffs_init_raw_objs(struct yaffs_dev *dev)
 {
-       yaffs_Allocator *allocator = dev->allocator;
+       struct yaffs_allocator *allocator = dev->allocator;
 
-       if(allocator) {
-               allocator->allocated_list = NULL;
-               allocator->freeObjects = NULL;
-               allocator->nFreeObjects = 0;
+       if (allocator) {
+               allocator->allocated_obj_list = NULL;
+               allocator->free_objs = NULL;
+               allocator->n_free_objects = 0;
        } else
                YBUG();
 }
 
-static void yaffs_deinit_raw_objs(yaffs_dev_t *dev)
+static void yaffs_deinit_raw_objs(struct yaffs_dev *dev)
 {
-       yaffs_Allocator *allocator = dev->allocator;
-       yaffs_obj_list *tmp;
+       struct yaffs_allocator *allocator = dev->allocator;
+       struct yaffs_obj_list *tmp;
 
-       if(!allocator){
+       if (!allocator) {
                YBUG();
                return;
        }
 
-       while (allocator->allocated_list) {
-               tmp = allocator->allocated_list->next;
-               YFREE(allocator->allocated_list->objects);
-               YFREE(allocator->allocated_list);
+       while (allocator->allocated_obj_list) {
+               tmp = allocator->allocated_obj_list->next;
+               YFREE(allocator->allocated_obj_list->objects);
+               YFREE(allocator->allocated_obj_list);
 
-               allocator->allocated_list = tmp;
+               allocator->allocated_obj_list = tmp;
        }
 
-       allocator->freeObjects = NULL;
-       allocator->nFreeObjects = 0;
-       allocator->n_objCreated = 0;
+       allocator->free_objs = NULL;
+       allocator->n_free_objects = 0;
+       allocator->n_obj_created = 0;
 }
 
-
-static int yaffs_create_free_objs(yaffs_dev_t *dev, int n_obj)
+static int yaffs_create_free_objs(struct yaffs_dev *dev, int n_obj)
 {
-       yaffs_Allocator *allocator = dev->allocator;
+       struct yaffs_allocator *allocator = dev->allocator;
 
        int i;
-       yaffs_obj_t *newObjects;
-       yaffs_obj_list *list;
+       struct yaffs_obj *new_objs;
+       struct yaffs_obj_list *list;
 
-       if(!allocator){
+       if (!allocator) {
                YBUG();
                return YAFFS_FAIL;
        }
@@ -300,15 +287,15 @@ static int yaffs_create_free_objs(yaffs_dev_t *dev, int n_obj)
                return YAFFS_OK;
 
        /* make these things */
-       newObjects = YMALLOC(n_obj * sizeof(yaffs_obj_t));
-       list = YMALLOC(sizeof(yaffs_obj_list));
+       new_objs = YMALLOC(n_obj * sizeof(struct yaffs_obj));
+       list = YMALLOC(sizeof(struct yaffs_obj_list));
 
-       if (!newObjects || !list) {
-               if (newObjects){
-                       YFREE(newObjects);
-                       newObjects = NULL;
+       if (!new_objs || !list) {
+               if (new_objs) {
+                       YFREE(new_objs);
+                       new_objs = NULL;
                }
-               if (list){
+               if (list) {
                        YFREE(list);
                        list = NULL;
                }
@@ -319,83 +306,82 @@ static int yaffs_create_free_objs(yaffs_dev_t *dev, int n_obj)
 
        /* Hook them into the free list */
        for (i = 0; i < n_obj - 1; i++) {
-               newObjects[i].siblings.next =
-                               (struct ylist_head *)(&newObjects[i + 1]);
+               new_objs[i].siblings.next =
+                   (struct list_head *)(&new_objs[i + 1]);
        }
 
-       newObjects[n_obj - 1].siblings.next = (void *)allocator->freeObjects;
-       allocator->freeObjects = newObjects;
-       allocator->nFreeObjects += n_obj;
-       allocator->n_objCreated += n_obj;
+       new_objs[n_obj - 1].siblings.next = (void *)allocator->free_objs;
+       allocator->free_objs = new_objs;
+       allocator->n_free_objects += n_obj;
+       allocator->n_obj_created += n_obj;
 
        /* Now add this bunch of Objects to a list for freeing up. */
 
-       list->objects = newObjects;
-       list->next = allocator->allocated_list;
-       allocator->allocated_list = list;
+       list->objects = new_objs;
+       list->next = allocator->allocated_obj_list;
+       allocator->allocated_obj_list = list;
 
        return YAFFS_OK;
 }
 
-yaffs_obj_t *yaffs_alloc_raw_obj(yaffs_dev_t *dev)
+struct yaffs_obj *yaffs_alloc_raw_obj(struct yaffs_dev *dev)
 {
-       yaffs_obj_t *obj = NULL;
-       yaffs_Allocator *allocator = dev->allocator;
+       struct yaffs_obj *obj = NULL;
+       struct yaffs_allocator *allocator = dev->allocator;
 
-       if(!allocator) {
+       if (!allocator) {
                YBUG();
                return obj;
        }
 
        /* If there are none left make more */
-       if (!allocator->freeObjects)
+       if (!allocator->free_objs)
                yaffs_create_free_objs(dev, YAFFS_ALLOCATION_NOBJECTS);
 
-       if (allocator->freeObjects) {
-               obj = allocator->freeObjects;
-               allocator->freeObjects =
-                       (yaffs_obj_t *) (allocator->freeObjects->siblings.next);
-               allocator->nFreeObjects--;
+       if (allocator->free_objs) {
+               obj = allocator->free_objs;
+               allocator->free_objs =
+                   (struct yaffs_obj *)(allocator->free_objs->siblings.next);
+               allocator->n_free_objects--;
        }
 
        return obj;
 }
 
-
-void yaffs_free_raw_obj(yaffs_dev_t *dev, yaffs_obj_t *obj)
+void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj)
 {
 
-       yaffs_Allocator *allocator = dev->allocator;
+       struct yaffs_allocator *allocator = dev->allocator;
 
-       if(!allocator)
+       if (!allocator)
                YBUG();
        else {
                /* Link into the free list. */
-               obj->siblings.next = (struct ylist_head *)(allocator->freeObjects);
-               allocator->freeObjects = obj;
-               allocator->nFreeObjects++;
+               obj->siblings.next = (struct list_head *)(allocator->free_objs);
+               allocator->free_objs = obj;
+               allocator->n_free_objects++;
        }
 }
 
-void yaffs_deinit_raw_tnodes_and_objs(yaffs_dev_t *dev)
+void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev)
 {
-       if(dev->allocator){
+       if (dev->allocator) {
                yaffs_deinit_raw_tnodes(dev);
                yaffs_deinit_raw_objs(dev);
 
                YFREE(dev->allocator);
-               dev->allocator=NULL;
+               dev->allocator = NULL;
        } else
                YBUG();
 }
 
-void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev)
+void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev)
 {
-       yaffs_Allocator *allocator;
+       struct yaffs_allocator *allocator;
 
-       if(!dev->allocator){
-               allocator = YMALLOC(sizeof(yaffs_Allocator));
-               if(allocator){
+       if (!dev->allocator) {
+               allocator = YMALLOC(sizeof(struct yaffs_allocator));
+               if (allocator) {
                        dev->allocator = allocator;
                        yaffs_init_raw_tnodes(dev);
                        yaffs_init_raw_objs(dev);
@@ -404,5 +390,4 @@ void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev)
                YBUG();
 }
 
-
 #endif
index 777f3b0..4d5f2ae 100644 (file)
 
 #include "yaffs_guts.h"
 
-void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev);
-void yaffs_deinit_raw_tnodes_and_objs(yaffs_dev_t *dev);
+void yaffs_init_raw_tnodes_and_objs(struct yaffs_dev *dev);
+void yaffs_deinit_raw_tnodes_and_objs(struct yaffs_dev *dev);
 
-yaffs_tnode_t *yaffs_alloc_raw_tnode(yaffs_dev_t *dev);
-void yaffs_free_raw_tnode(yaffs_dev_t *dev, yaffs_tnode_t *tn);
+struct yaffs_tnode *yaffs_alloc_raw_tnode(struct yaffs_dev *dev);
+void yaffs_free_raw_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn);
 
-yaffs_obj_t *yaffs_alloc_raw_obj(yaffs_dev_t *dev);
-void yaffs_free_raw_obj(yaffs_dev_t *dev, yaffs_obj_t *obj);
+struct yaffs_obj *yaffs_alloc_raw_obj(struct yaffs_dev *dev);
+void yaffs_free_raw_obj(struct yaffs_dev *dev, struct yaffs_obj *obj);
 
 #endif
diff --git a/yaffs_attribs.c b/yaffs_attribs.c
new file mode 100644 (file)
index 0000000..aaf4685
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2010 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "yaffs_guts.h"
+#include "yaffs_attribs.h"
+
+void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh)
+{
+       obj->yst_uid = oh->yst_uid;
+       obj->yst_gid = oh->yst_gid;
+       obj->yst_atime = oh->yst_atime;
+       obj->yst_mtime = oh->yst_mtime;
+       obj->yst_ctime = oh->yst_ctime;
+       obj->yst_rdev = oh->yst_rdev;
+}
+
+void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj)
+{
+       oh->yst_uid = obj->yst_uid;
+       oh->yst_gid = obj->yst_gid;
+       oh->yst_atime = obj->yst_atime;
+       oh->yst_mtime = obj->yst_mtime;
+       oh->yst_ctime = obj->yst_ctime;
+       oh->yst_rdev = obj->yst_rdev;
+
+}
+
+void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c)
+{
+       obj->yst_mtime = Y_CURRENT_TIME;
+       if (do_a)
+               obj->yst_atime = obj->yst_atime;
+       if (do_c)
+               obj->yst_ctime = obj->yst_atime;
+}
+
+void yaffs_attribs_init(struct yaffs_obj *obj, u32 gid, u32 uid, u32 rdev)
+{
+       yaffs_load_current_time(obj, 1, 1);
+       obj->yst_rdev = rdev;
+       obj->yst_uid = uid;
+       obj->yst_gid = gid;
+}
+
+loff_t yaffs_get_file_size(struct yaffs_obj *obj)
+{
+       YCHAR *alias = NULL;
+       obj = yaffs_get_equivalent_obj(obj);
+
+       switch (obj->variant_type) {
+       case YAFFS_OBJECT_TYPE_FILE:
+               return obj->variant.file_variant.file_size;
+       case YAFFS_OBJECT_TYPE_SYMLINK:
+               alias = obj->variant.symlink_variant.alias;
+               if (!alias)
+                       return 0;
+               return yaffs_strnlen(alias, YAFFS_MAX_ALIAS_LENGTH);
+       default:
+               return 0;
+       }
+}
+
+int yaffs_set_attribs(struct yaffs_obj *obj, struct iattr *attr)
+{
+       unsigned int valid = attr->ia_valid;
+
+       if (valid & ATTR_MODE)
+               obj->yst_mode = attr->ia_mode;
+       if (valid & ATTR_UID)
+               obj->yst_uid = attr->ia_uid;
+       if (valid & ATTR_GID)
+               obj->yst_gid = attr->ia_gid;
+
+       if (valid & ATTR_ATIME)
+               obj->yst_atime = Y_TIME_CONVERT(attr->ia_atime);
+       if (valid & ATTR_CTIME)
+               obj->yst_ctime = Y_TIME_CONVERT(attr->ia_ctime);
+       if (valid & ATTR_MTIME)
+               obj->yst_mtime = Y_TIME_CONVERT(attr->ia_mtime);
+
+       if (valid & ATTR_SIZE)
+               yaffs_resize_file(obj, attr->ia_size);
+
+       yaffs_update_oh(obj, NULL, 1, 0, 0, NULL);
+
+       return YAFFS_OK;
+
+}
+
+int yaffs_get_attribs(struct yaffs_obj *obj, struct iattr *attr)
+{
+       unsigned int valid = 0;
+
+       attr->ia_mode = obj->yst_mode;
+       valid |= ATTR_MODE;
+       attr->ia_uid = obj->yst_uid;
+       valid |= ATTR_UID;
+       attr->ia_gid = obj->yst_gid;
+       valid |= ATTR_GID;
+
+       Y_TIME_CONVERT(attr->ia_atime) = obj->yst_atime;
+       valid |= ATTR_ATIME;
+       Y_TIME_CONVERT(attr->ia_ctime) = obj->yst_ctime;
+       valid |= ATTR_CTIME;
+       Y_TIME_CONVERT(attr->ia_mtime) = obj->yst_mtime;
+       valid |= ATTR_MTIME;
+
+       attr->ia_size = yaffs_get_file_size(obj);
+       valid |= ATTR_SIZE;
+
+       attr->ia_valid = valid;
+
+       return YAFFS_OK;
+}
similarity index 50%
rename from yaffs_qsort.h
rename to yaffs_attribs.h
index 4a4981b..33d541d 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
+#ifndef __YAFFS_ATTRIBS_H__
+#define __YAFFS_ATTRIBS_H__
 
-#ifndef __YAFFS_QSORT_H__
-#define __YAFFS_QSORT_H__
+#include "yaffs_guts.h"
 
-#ifdef __KERNEL__
-#include <linux/sort.h>
+void yaffs_load_attribs(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh);
+void yaffs_load_attribs_oh(struct yaffs_obj_hdr *oh, struct yaffs_obj *obj);
+void yaffs_attribs_init(struct yaffs_obj *obj, u32 gid, u32 uid, u32 rdev);
+void yaffs_load_current_time(struct yaffs_obj *obj, int do_a, int do_c);
+int yaffs_set_attribs(struct yaffs_obj *obj, struct iattr *attr);
+int yaffs_get_attribs(struct yaffs_obj *obj, struct iattr *attr);
 
-extern void yaffs_qsort(void *const base, size_t total_elems, size_t size,
-                       int (*cmp)(const void *, const void *)){
-       sort(base, total_elems, size, cmp, NULL);
-}
-
-#else
-
-extern void yaffs_qsort(void *const base, size_t total_elems, size_t size,
-                       int (*cmp)(const void *, const void *));
-
-#endif
 #endif
index 85c8c1d..5d1cfb2 100644 (file)
  * Chunk bitmap manipulations
  */
 
-static Y_INLINE __u8 *yaffs_block_bits(yaffs_dev_t *dev, int blk)
+static Y_INLINE u8 *yaffs_block_bits(struct yaffs_dev *dev, int blk)
 {
        if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
                T(YAFFS_TRACE_ERROR,
-                       (TSTR("**>> yaffs: BlockBits block %d is not valid" TENDSTR),
-                       blk));
+                 (TSTR("**>> yaffs: BlockBits block %d is not valid" TENDSTR),
+                  blk));
                YBUG();
        }
        return dev->chunk_bits +
-               (dev->chunk_bit_stride * (blk - dev->internal_start_block));
+           (dev->chunk_bit_stride * (blk - dev->internal_start_block));
 }
 
-void yaffs_verify_chunk_bit_id(yaffs_dev_t *dev, int blk, int chunk)
+void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk)
 {
        if (blk < dev->internal_start_block || blk > dev->internal_end_block ||
-                       chunk < 0 || chunk >= dev->param.chunks_per_block) {
+           chunk < 0 || chunk >= dev->param.chunks_per_block) {
                T(YAFFS_TRACE_ERROR,
-               (TSTR("**>> yaffs: Chunk Id (%d:%d) invalid"TENDSTR),
-                       blk, chunk));
+                 (TSTR("**>> yaffs: Chunk Id (%d:%d) invalid" TENDSTR),
+                  blk, chunk));
                YBUG();
        }
 }
 
-void yaffs_clear_chunk_bits(yaffs_dev_t *dev, int blk)
+void yaffs_clear_chunk_bits(struct yaffs_dev *dev, int blk)
 {
-       __u8 *blk_bits = yaffs_block_bits(dev, blk);
+       u8 *blk_bits = yaffs_block_bits(dev, blk);
 
        memset(blk_bits, 0, dev->chunk_bit_stride);
 }
 
-void yaffs_clear_chunk_bit(yaffs_dev_t *dev, int blk, int chunk)
+void yaffs_clear_chunk_bit(struct yaffs_dev *dev, int blk, int chunk)
 {
-       __u8 *blk_bits = yaffs_block_bits(dev, blk);
+       u8 *blk_bits = yaffs_block_bits(dev, blk);
 
        yaffs_verify_chunk_bit_id(dev, blk, chunk);
 
        blk_bits[chunk / 8] &= ~(1 << (chunk & 7));
 }
 
-void yaffs_set_chunk_bit(yaffs_dev_t *dev, int blk, int chunk)
+void yaffs_set_chunk_bit(struct yaffs_dev *dev, int blk, int chunk)
 {
-       __u8 *blk_bits = yaffs_block_bits(dev, blk);
+       u8 *blk_bits = yaffs_block_bits(dev, blk);
 
        yaffs_verify_chunk_bit_id(dev, blk, chunk);
 
        blk_bits[chunk / 8] |= (1 << (chunk & 7));
 }
 
-int yaffs_check_chunk_bit(yaffs_dev_t *dev, int blk, int chunk)
+int yaffs_check_chunk_bit(struct yaffs_dev *dev, int blk, int chunk)
 {
-       __u8 *blk_bits = yaffs_block_bits(dev, blk);
+       u8 *blk_bits = yaffs_block_bits(dev, blk);
        yaffs_verify_chunk_bit_id(dev, blk, chunk);
 
        return (blk_bits[chunk / 8] & (1 << (chunk & 7))) ? 1 : 0;
 }
 
-int yaffs_still_some_chunks(yaffs_dev_t *dev, int blk)
+int yaffs_still_some_chunks(struct yaffs_dev *dev, int blk)
 {
-       __u8 *blk_bits = yaffs_block_bits(dev, blk);
+       u8 *blk_bits = yaffs_block_bits(dev, blk);
        int i;
        for (i = 0; i < dev->chunk_bit_stride; i++) {
                if (*blk_bits)
@@ -85,13 +85,13 @@ int yaffs_still_some_chunks(yaffs_dev_t *dev, int blk)
        return 0;
 }
 
-int yaffs_count_chunk_bits(yaffs_dev_t *dev, int blk)
+int yaffs_count_chunk_bits(struct yaffs_dev *dev, int blk)
 {
-       __u8 *blk_bits = yaffs_block_bits(dev, blk);
+       u8 *blk_bits = yaffs_block_bits(dev, blk);
        int i;
        int n = 0;
        for (i = 0; i < dev->chunk_bit_stride; i++) {
-               __u8 x = *blk_bits;
+               u8 x = *blk_bits;
                while (x) {
                        if (x & 1)
                                n++;
@@ -102,4 +102,3 @@ int yaffs_count_chunk_bits(yaffs_dev_t *dev, int blk)
        }
        return n;
 }
-
index ea755be..cf9ea58 100644 (file)
 
 #include "yaffs_guts.h"
 
-void yaffs_verify_chunk_bit_id(yaffs_dev_t *dev, int blk, int chunk);
-void yaffs_clear_chunk_bits(yaffs_dev_t *dev, int blk);
-void yaffs_clear_chunk_bit(yaffs_dev_t *dev, int blk, int chunk);
-void yaffs_set_chunk_bit(yaffs_dev_t *dev, int blk, int chunk);
-int yaffs_check_chunk_bit(yaffs_dev_t *dev, int blk, int chunk);
-int yaffs_still_some_chunks(yaffs_dev_t *dev, int blk);
-int yaffs_count_chunk_bits(yaffs_dev_t *dev, int blk);
+void yaffs_verify_chunk_bit_id(struct yaffs_dev *dev, int blk, int chunk);
+void yaffs_clear_chunk_bits(struct yaffs_dev *dev, int blk);
+void yaffs_clear_chunk_bit(struct yaffs_dev *dev, int blk, int chunk);
+void yaffs_set_chunk_bit(struct yaffs_dev *dev, int blk, int chunk);
+int yaffs_check_chunk_bit(struct yaffs_dev *dev, int blk, int chunk);
+int yaffs_still_some_chunks(struct yaffs_dev *dev, int blk);
+int yaffs_count_chunk_bits(struct yaffs_dev *dev, int blk);
 
 #endif
index 82d6874..2cb144c 100644 (file)
 #include "yaffs_checkptrw.h"
 #include "yaffs_getblockinfo.h"
 
-static int yaffs2_checkpt_space_ok(yaffs_dev_t *dev)
+static int yaffs2_checkpt_space_ok(struct yaffs_dev *dev)
 {
        int blocks_avail = dev->n_erased_blocks - dev->param.n_reserved_blocks;
 
        T(YAFFS_TRACE_CHECKPOINT,
-               (TSTR("checkpt blocks available = %d" TENDSTR),
-               blocks_avail));
+         (TSTR("checkpt blocks available = %d" TENDSTR), blocks_avail));
 
        return (blocks_avail <= 0) ? 0 : 1;
 }
 
-
-static int yaffs_checkpt_erase(yaffs_dev_t *dev)
+static int yaffs_checkpt_erase(struct yaffs_dev *dev)
 {
        int i;
 
        if (!dev->param.erase_fn)
                return 0;
-       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checking blocks %d to %d"TENDSTR),
-               dev->internal_start_block, dev->internal_end_block));
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checking blocks %d to %d" TENDSTR),
+                                  dev->internal_start_block,
+                                  dev->internal_end_block));
 
        for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) {
-               yaffs_block_info_t *bi = yaffs_get_block_info(dev, i);
+               struct yaffs_block_info *bi = yaffs_get_block_info(dev, i);
                if (bi->block_state == YAFFS_BLOCK_STATE_CHECKPOINT) {
-                       T(YAFFS_TRACE_CHECKPOINT, (TSTR("erasing checkpt block %d"TENDSTR), i));
+                       T(YAFFS_TRACE_CHECKPOINT,
+                         (TSTR("erasing checkpt block %d" TENDSTR), i));
 
                        dev->n_erasures++;
 
-                       if (dev->param.erase_fn(dev, i - dev->block_offset /* realign */)) {
+                       if (dev->param.
+                           erase_fn(dev,
+                                    i - dev->block_offset /* realign */ )) {
                                bi->block_state = YAFFS_BLOCK_STATE_EMPTY;
                                dev->n_erased_blocks++;
-                               dev->n_free_chunks += dev->param.chunks_per_block;
+                               dev->n_free_chunks +=
+                                   dev->param.chunks_per_block;
                        } else {
                                dev->param.bad_block_fn(dev, i);
                                bi->block_state = YAFFS_BLOCK_STATE_DEAD;
@@ -58,93 +61,103 @@ static int yaffs_checkpt_erase(yaffs_dev_t *dev)
        return 1;
 }
 
-
-static void yaffs2_checkpt_find_erased_block(yaffs_dev_t *dev)
+static void yaffs2_checkpt_find_erased_block(struct yaffs_dev *dev)
 {
-       int  i;
+       int i;
        int blocks_avail = dev->n_erased_blocks - dev->param.n_reserved_blocks;
        T(YAFFS_TRACE_CHECKPOINT,
-               (TSTR("allocating checkpt block: erased %d reserved %d avail %d next %d "TENDSTR),
-               dev->n_erased_blocks, dev->param.n_reserved_blocks, blocks_avail, dev->checkpt_next_block));
+         (TSTR
+          ("allocating checkpt block: erased %d reserved %d avail %d next %d "
+           TENDSTR), dev->n_erased_blocks, dev->param.n_reserved_blocks,
+          blocks_avail, dev->checkpt_next_block));
 
        if (dev->checkpt_next_block >= 0 &&
-                       dev->checkpt_next_block <= dev->internal_end_block &&
-                       blocks_avail > 0) {
+           dev->checkpt_next_block <= dev->internal_end_block &&
+           blocks_avail > 0) {
 
-               for (i = dev->checkpt_next_block; i <= dev->internal_end_block; i++) {
-                       yaffs_block_info_t *bi = yaffs_get_block_info(dev, i);
+               for (i = dev->checkpt_next_block; i <= dev->internal_end_block;
+                    i++) {
+                       struct yaffs_block_info *bi =
+                           yaffs_get_block_info(dev, i);
                        if (bi->block_state == YAFFS_BLOCK_STATE_EMPTY) {
                                dev->checkpt_next_block = i + 1;
                                dev->checkpt_cur_block = i;
-                               T(YAFFS_TRACE_CHECKPOINT, (TSTR("allocating checkpt block %d"TENDSTR), i));
+                               T(YAFFS_TRACE_CHECKPOINT,
+                                 (TSTR("allocating checkpt block %d" TENDSTR),
+                                  i));
                                return;
                        }
                }
        }
-       T(YAFFS_TRACE_CHECKPOINT, (TSTR("out of checkpt blocks"TENDSTR)));
+       T(YAFFS_TRACE_CHECKPOINT, (TSTR("out of checkpt blocks" TENDSTR)));
 
        dev->checkpt_next_block = -1;
        dev->checkpt_cur_block = -1;
 }
 
-static void yaffs2_checkpt_find_block(yaffs_dev_t *dev)
+static void yaffs2_checkpt_find_block(struct yaffs_dev *dev)
 {
-       int  i;
-       yaffs_ext_tags tags;
+       int i;
+       struct yaffs_ext_tags tags;
 
-       T(YAFFS_TRACE_CHECKPOINT, (TSTR("find next checkpt block: start:  blocks %d next %d" TENDSTR),
-               dev->blocks_in_checkpt, dev->checkpt_next_block));
+       T(YAFFS_TRACE_CHECKPOINT,
+         (TSTR("find next checkpt block: start:  blocks %d next %d" TENDSTR),
+          dev->blocks_in_checkpt, dev->checkpt_next_block));
 
        if (dev->blocks_in_checkpt < dev->checkpt_max_blocks)
-               for (i = dev->checkpt_next_block; i <= dev->internal_end_block; i++) {
+               for (i = dev->checkpt_next_block; i <= dev->internal_end_block;
+                    i++) {
                        int chunk = i * dev->param.chunks_per_block;
                        int realigned_chunk = chunk - dev->chunk_offset;
 
                        dev->param.read_chunk_tags_fn(dev, realigned_chunk,
-                                       NULL, &tags);
-                       T(YAFFS_TRACE_CHECKPOINT, (TSTR("find next checkpt block: search: block %d oid %d seq %d eccr %d" TENDSTR),
-                               i, tags.obj_id, tags.seq_number, tags.ecc_result));
+                                                     NULL, &tags);
+                       T(YAFFS_TRACE_CHECKPOINT,
+                         (TSTR
+                          ("find next checkpt block: search: block %d oid %d seq %d eccr %d"
+                           TENDSTR), i, tags.obj_id, tags.seq_number,
+                          tags.ecc_result));
 
                        if (tags.seq_number == YAFFS_SEQUENCE_CHECKPOINT_DATA) {
                                /* Right kind of block */
                                dev->checkpt_next_block = tags.obj_id;
                                dev->checkpt_cur_block = i;
-                               dev->checkpt_block_list[dev->blocks_in_checkpt] = i;
+                               dev->checkpt_block_list[dev->
+                                                       blocks_in_checkpt] = i;
                                dev->blocks_in_checkpt++;
-                               T(YAFFS_TRACE_CHECKPOINT, (TSTR("found checkpt block %d"TENDSTR), i));
+                               T(YAFFS_TRACE_CHECKPOINT,
+                                 (TSTR("found checkpt block %d" TENDSTR), i));
                                return;
                        }
                }
 
-       T(YAFFS_TRACE_CHECKPOINT, (TSTR("found no more checkpt blocks"TENDSTR)));
+       T(YAFFS_TRACE_CHECKPOINT,
+         (TSTR("found no more checkpt blocks" TENDSTR)));
 
        dev->checkpt_next_block = -1;
        dev->checkpt_cur_block = -1;
 }
 
-
-int yaffs2_checkpt_open(yaffs_dev_t *dev, int writing)
+int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing)
 {
 
-
        dev->checkpt_open_write = writing;
 
        /* Got the functions we need? */
        if (!dev->param.write_chunk_tags_fn ||
-               !dev->param.read_chunk_tags_fn ||
-               !dev->param.erase_fn ||
-               !dev->param.bad_block_fn)
+           !dev->param.read_chunk_tags_fn ||
+           !dev->param.erase_fn || !dev->param.bad_block_fn)
                return 0;
 
        if (writing && !yaffs2_checkpt_space_ok(dev))
                return 0;
 
        if (!dev->checkpt_buffer)
-               dev->checkpt_buffer = YMALLOC_DMA(dev->param.total_bytes_per_chunk);
+               dev->checkpt_buffer =
+                   YMALLOC_DMA(dev->param.total_bytes_per_chunk);
        if (!dev->checkpt_buffer)
                return 0;
 
-
        dev->checkpt_page_seq = 0;
        dev->checkpt_byte_count = 0;
        dev->checkpt_sum = 0;
@@ -165,9 +178,12 @@ int yaffs2_checkpt_open(yaffs_dev_t *dev, int writing)
                /* A checkpoint block list of 1 checkpoint block per 16 block is (hopefully)
                 * going to be way more than we need */
                dev->blocks_in_checkpt = 0;
-               dev->checkpt_max_blocks = (dev->internal_end_block - dev->internal_start_block)/16 + 2;
-               dev->checkpt_block_list = YMALLOC(sizeof(int) * dev->checkpt_max_blocks);
-               if(!dev->checkpt_block_list)
+               dev->checkpt_max_blocks =
+                   (dev->internal_end_block - dev->internal_start_block) / 16 +
+                   2;
+               dev->checkpt_block_list =
+                   YMALLOC(sizeof(int) * dev->checkpt_max_blocks);
+               if (!dev->checkpt_block_list)
                        return 0;
 
                for (i = 0; i < dev->checkpt_max_blocks; i++)
@@ -177,20 +193,20 @@ int yaffs2_checkpt_open(yaffs_dev_t *dev, int writing)
        return 1;
 }
 
-int yaffs2_get_checkpt_sum(yaffs_dev_t *dev, __u32 *sum)
+int yaffs2_get_checkpt_sum(struct yaffs_dev *dev, u32 * sum)
 {
-       __u32 composite_sum;
-       composite_sum =  (dev->checkpt_sum << 8) | (dev->checkpt_xor & 0xFF);
+       u32 composite_sum;
+       composite_sum = (dev->checkpt_sum << 8) | (dev->checkpt_xor & 0xFF);
        *sum = composite_sum;
        return 1;
 }
 
-static int yaffs2_checkpt_flush_buffer(yaffs_dev_t *dev)
+static int yaffs2_checkpt_flush_buffer(struct yaffs_dev *dev)
 {
        int chunk;
        int realigned_chunk;
 
-       yaffs_ext_tags tags;
+       struct yaffs_ext_tags tags;
 
        if (dev->checkpt_cur_block < 0) {
                yaffs2_checkpt_find_erased_block(dev);
@@ -201,30 +217,35 @@ static int yaffs2_checkpt_flush_buffer(yaffs_dev_t *dev)
                return 0;
 
        tags.is_deleted = 0;
-       tags.obj_id = dev->checkpt_next_block; /* Hint to next place to look */
+       tags.obj_id = dev->checkpt_next_block;  /* Hint to next place to look */
        tags.chunk_id = dev->checkpt_page_seq + 1;
-       tags.seq_number =  YAFFS_SEQUENCE_CHECKPOINT_DATA;
+       tags.seq_number = YAFFS_SEQUENCE_CHECKPOINT_DATA;
        tags.n_bytes = dev->data_bytes_per_chunk;
        if (dev->checkpt_cur_chunk == 0) {
                /* First chunk we write for the block? Set block state to
                   checkpoint */
-               yaffs_block_info_t *bi = yaffs_get_block_info(dev, dev->checkpt_cur_block);
+               struct yaffs_block_info *bi =
+                   yaffs_get_block_info(dev, dev->checkpt_cur_block);
                bi->block_state = YAFFS_BLOCK_STATE_CHECKPOINT;
                dev->blocks_in_checkpt++;
        }
 
-       chunk = dev->checkpt_cur_block * dev->param.chunks_per_block + dev->checkpt_cur_chunk;
-
+       chunk =
+           dev->checkpt_cur_block * dev->param.chunks_per_block +
+           dev->checkpt_cur_chunk;
 
-       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR),
-               chunk, dev->checkpt_cur_block, dev->checkpt_cur_chunk, tags.obj_id, tags.chunk_id));
+       T(YAFFS_TRACE_CHECKPOINT,
+         (TSTR
+          ("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR),
+          chunk, dev->checkpt_cur_block, dev->checkpt_cur_chunk, tags.obj_id,
+          tags.chunk_id));
 
        realigned_chunk = chunk - dev->chunk_offset;
 
        dev->n_page_writes++;
 
        dev->param.write_chunk_tags_fn(dev, realigned_chunk,
-                       dev->checkpt_buffer, &tags);
+                                      dev->checkpt_buffer, &tags);
        dev->checkpt_byte_offs = 0;
        dev->checkpt_page_seq++;
        dev->checkpt_cur_chunk++;
@@ -237,16 +258,12 @@ static int yaffs2_checkpt_flush_buffer(yaffs_dev_t *dev)
        return 1;
 }
 
-
-int yaffs2_checkpt_wr(yaffs_dev_t *dev, const void *data, int n_bytes)
+int yaffs2_checkpt_wr(struct yaffs_dev *dev, const void *data, int n_bytes)
 {
        int i = 0;
        int ok = 1;
 
-
-       __u8 * data_bytes = (__u8 *)data;
-
-
+       u8 *data_bytes = (u8 *) data;
 
        if (!dev->checkpt_buffer)
                return 0;
@@ -264,26 +281,24 @@ int yaffs2_checkpt_wr(yaffs_dev_t *dev, const void *data, int n_bytes)
                data_bytes++;
                dev->checkpt_byte_count++;
 
-
                if (dev->checkpt_byte_offs < 0 ||
-                  dev->checkpt_byte_offs >= dev->data_bytes_per_chunk)
+                   dev->checkpt_byte_offs >= dev->data_bytes_per_chunk)
                        ok = yaffs2_checkpt_flush_buffer(dev);
        }
 
        return i;
 }
 
-int yaffs2_checkpt_rd(yaffs_dev_t *dev, void *data, int n_bytes)
+int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes)
 {
        int i = 0;
        int ok = 1;
-       yaffs_ext_tags tags;
-
+       struct yaffs_ext_tags tags;
 
        int chunk;
        int realigned_chunk;
 
-       __u8 *data_bytes = (__u8 *)data;
+       u8 *data_bytes = (u8 *) data;
 
        if (!dev->checkpt_buffer)
                return 0;
@@ -293,9 +308,8 @@ int yaffs2_checkpt_rd(yaffs_dev_t *dev, void *data, int n_bytes)
 
        while (i < n_bytes && ok) {
 
-
                if (dev->checkpt_byte_offs < 0 ||
-                       dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) {
+                   dev->checkpt_byte_offs >= dev->data_bytes_per_chunk) {
 
                        if (dev->checkpt_cur_block < 0) {
                                yaffs2_checkpt_find_block(dev);
@@ -306,35 +320,39 @@ int yaffs2_checkpt_rd(yaffs_dev_t *dev, void *data, int n_bytes)
                                ok = 0;
                        else {
                                chunk = dev->checkpt_cur_block *
-                                       dev->param.chunks_per_block +
-                                       dev->checkpt_cur_chunk;
+                                   dev->param.chunks_per_block +
+                                   dev->checkpt_cur_chunk;
 
                                realigned_chunk = chunk - dev->chunk_offset;
-                               
+
                                dev->n_page_reads++;
 
                                /* read in the next chunk */
                                dev->param.read_chunk_tags_fn(dev,
-                                               realigned_chunk,
-                                               dev->checkpt_buffer,
-                                               &tags);
-
-                               if (tags.chunk_id != (dev->checkpt_page_seq + 1) ||
-                                       tags.ecc_result > YAFFS_ECC_RESULT_FIXED ||
-                                       tags.seq_number != YAFFS_SEQUENCE_CHECKPOINT_DATA)
+                                                             realigned_chunk,
+                                                             dev->
+                                                             checkpt_buffer,
+                                                             &tags);
+
+                               if (tags.chunk_id != (dev->checkpt_page_seq + 1)
+                                   || tags.ecc_result > YAFFS_ECC_RESULT_FIXED
+                                   || tags.seq_number !=
+                                   YAFFS_SEQUENCE_CHECKPOINT_DATA)
                                        ok = 0;
 
                                dev->checkpt_byte_offs = 0;
                                dev->checkpt_page_seq++;
                                dev->checkpt_cur_chunk++;
 
-                               if (dev->checkpt_cur_chunk >= dev->param.chunks_per_block)
+                               if (dev->checkpt_cur_chunk >=
+                                   dev->param.chunks_per_block)
                                        dev->checkpt_cur_block = -1;
                        }
                }
 
                if (ok) {
-                       *data_bytes = dev->checkpt_buffer[dev->checkpt_byte_offs];
+                       *data_bytes =
+                           dev->checkpt_buffer[dev->checkpt_byte_offs];
                        dev->checkpt_sum += *data_bytes;
                        dev->checkpt_xor ^= *data_bytes;
                        dev->checkpt_byte_offs++;
@@ -344,21 +362,24 @@ int yaffs2_checkpt_rd(yaffs_dev_t *dev, void *data, int n_bytes)
                }
        }
 
-       return  i;
+       return i;
 }
 
-int yaffs_checkpt_close(yaffs_dev_t *dev)
+int yaffs_checkpt_close(struct yaffs_dev *dev)
 {
 
        if (dev->checkpt_open_write) {
                if (dev->checkpt_byte_offs != 0)
                        yaffs2_checkpt_flush_buffer(dev);
-       } else if(dev->checkpt_block_list){
+       } else if (dev->checkpt_block_list) {
                int i;
-               for (i = 0; i < dev->blocks_in_checkpt && dev->checkpt_block_list[i] >= 0; i++) {
+               for (i = 0;
+                    i < dev->blocks_in_checkpt
+                    && dev->checkpt_block_list[i] >= 0; i++) {
                        int blk = dev->checkpt_block_list[i];
-                       yaffs_block_info_t *bi = NULL;
-                       if( dev->internal_start_block <= blk && blk <= dev->internal_end_block)
+                       struct yaffs_block_info *bi = NULL;
+                       if (dev->internal_start_block <= blk
+                           && blk <= dev->internal_end_block)
                                bi = yaffs_get_block_info(dev, blk);
                        if (bi && bi->block_state == YAFFS_BLOCK_STATE_EMPTY)
                                bi->block_state = YAFFS_BLOCK_STATE_CHECKPOINT;
@@ -370,12 +391,12 @@ int yaffs_checkpt_close(yaffs_dev_t *dev)
                dev->checkpt_block_list = NULL;
        }
 
-       dev->n_free_chunks -= dev->blocks_in_checkpt * dev->param.chunks_per_block;
+       dev->n_free_chunks -=
+           dev->blocks_in_checkpt * dev->param.chunks_per_block;
        dev->n_erased_blocks -= dev->blocks_in_checkpt;
 
-
        T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint byte count %d" TENDSTR),
-                       dev->checkpt_byte_count));
+                                  dev->checkpt_byte_count));
 
        if (dev->checkpt_buffer) {
                /* free the buffer */
@@ -386,15 +407,13 @@ int yaffs_checkpt_close(yaffs_dev_t *dev)
                return 0;
 }
 
-int yaffs2_checkpt_invalidate_stream(yaffs_dev_t *dev)
+int yaffs2_checkpt_invalidate_stream(struct yaffs_dev *dev)
 {
        /* Erase the checkpoint data */
 
-       T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint invalidate of %d blocks"TENDSTR),
-               dev->blocks_in_checkpt));
+       T(YAFFS_TRACE_CHECKPOINT,
+         (TSTR("checkpoint invalidate of %d blocks" TENDSTR),
+          dev->blocks_in_checkpt));
 
        return yaffs_checkpt_erase(dev);
 }
-
-
-
index 582b89c..361c606 100644 (file)
 
 #include "yaffs_guts.h"
 
-int yaffs2_checkpt_open(yaffs_dev_t *dev, int writing);
+int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing);
 
-int yaffs2_checkpt_wr(yaffs_dev_t *dev, const void *data, int n_bytes);
+int yaffs2_checkpt_wr(struct yaffs_dev *dev, const void *data, int n_bytes);
 
-int yaffs2_checkpt_rd(yaffs_dev_t *dev, void *data, int n_bytes);
+int yaffs2_checkpt_rd(struct yaffs_dev *dev, void *data, int n_bytes);
 
-int yaffs2_get_checkpt_sum(yaffs_dev_t *dev, __u32 *sum);
+int yaffs2_get_checkpt_sum(struct yaffs_dev *dev, u32 * sum);
 
-int yaffs_checkpt_close(yaffs_dev_t *dev);
-
-int yaffs2_checkpt_invalidate_stream(yaffs_dev_t *dev);
+int yaffs_checkpt_close(struct yaffs_dev *dev);
 
+int yaffs2_checkpt_invalidate_stream(struct yaffs_dev *dev);
 
 #endif
index 35f8747..0ea0305 100644 (file)
@@ -106,7 +106,7 @@ void yaffs_ecc_cacl(const unsigned char *data, unsigned char *ecc)
                b = column_parity_table[*data++];
                col_parity ^= b;
 
-               if (b & 0x01) {         /* odd number of bits in the byte */
+               if (b & 0x01) { /* odd number of bits in the byte */
                        line_parity ^= i;
                        line_parity_prime ^= ~i;
                }
@@ -160,11 +160,10 @@ void yaffs_ecc_cacl(const unsigned char *data, unsigned char *ecc)
 #endif
 }
 
-
 /* Correct the ECC on a 256 byte block of data */
 
 int yaffs_ecc_correct(unsigned char *data, unsigned char *read_ecc,
-                    const unsigned char *test_ecc)
+                     const unsigned char *test_ecc)
 {
        unsigned char d0, d1, d2;       /* deltas */
 
@@ -173,7 +172,7 @@ int yaffs_ecc_correct(unsigned char *data, unsigned char *read_ecc,
        d2 = read_ecc[2] ^ test_ecc[2];
 
        if ((d0 | d1 | d2) == 0)
-               return 0; /* no error */
+               return 0;       /* no error */
 
        if (((d0 ^ (d0 >> 1)) & 0x55) == 0x55 &&
            ((d1 ^ (d1 >> 1)) & 0x55) == 0x55 &&
@@ -220,19 +219,18 @@ int yaffs_ecc_correct(unsigned char *data, unsigned char *read_ecc,
 
                data[byte] ^= (1 << bit);
 
-               return 1; /* Corrected the error */
+               return 1;       /* Corrected the error */
        }
 
        if ((yaffs_count_bits(d0) +
-            yaffs_count_bits(d1) +
-            yaffs_count_bits(d2)) ==  1) {
+            yaffs_count_bits(d1) + yaffs_count_bits(d2)) == 1) {
                /* Reccoverable error in ecc */
 
                read_ecc[0] = test_ecc[0];
                read_ecc[1] = test_ecc[1];
                read_ecc[2] = test_ecc[2];
 
-               return 1; /* Corrected the error */
+               return 1;       /* Corrected the error */
        }
 
        /* Unrecoverable error */
@@ -241,12 +239,11 @@ int yaffs_ecc_correct(unsigned char *data, unsigned char *read_ecc,
 
 }
 
-
 /*
  * ECCxxxOther does ECC calcs on arbitrary n bytes of data
  */
 void yaffs_ecc_calc_other(const unsigned char *data, unsigned n_bytes,
-                               yaffs_ecc_other *ecc_other)
+                         struct yaffs_ecc_other *ecc_other)
 {
        unsigned int i;
 
@@ -259,7 +256,7 @@ void yaffs_ecc_calc_other(const unsigned char *data, unsigned n_bytes,
                b = column_parity_table[*data++];
                col_parity ^= b;
 
-               if (b & 0x01)    {
+               if (b & 0x01) {
                        /* odd number of bits in the byte */
                        line_parity ^= i;
                        line_parity_prime ^= ~i;
@@ -273,8 +270,8 @@ void yaffs_ecc_calc_other(const unsigned char *data, unsigned n_bytes,
 }
 
 int yaffs_ecc_correct_other(unsigned char *data, unsigned n_bytes,
-                       yaffs_ecc_other *read_ecc,
-                       const yaffs_ecc_other *test_ecc)
+                           struct yaffs_ecc_other *read_ecc,
+                           const struct yaffs_ecc_other *test_ecc)
 {
        unsigned char delta_col;        /* column parity delta */
        unsigned delta_line;    /* line parity delta */
@@ -283,10 +280,11 @@ int yaffs_ecc_correct_other(unsigned char *data, unsigned n_bytes,
 
        delta_col = read_ecc->col_parity ^ test_ecc->col_parity;
        delta_line = read_ecc->line_parity ^ test_ecc->line_parity;
-       delta_line_prime = read_ecc->line_parity_prime ^ test_ecc->line_parity_prime;
+       delta_line_prime =
+           read_ecc->line_parity_prime ^ test_ecc->line_parity_prime;
 
        if ((delta_col | delta_line | delta_line_prime) == 0)
-               return 0; /* no error */
+               return 0;       /* no error */
 
        if (delta_line == ~delta_line_prime &&
            (((delta_col ^ (delta_col >> 1)) & 0x15) == 0x15)) {
@@ -306,15 +304,16 @@ int yaffs_ecc_correct_other(unsigned char *data, unsigned n_bytes,
 
                data[delta_line] ^= (1 << bit);
 
-               return 1; /* corrected */
+               return 1;       /* corrected */
        }
 
-       if ((yaffs_count_bits32(delta_line) + yaffs_count_bits32(delta_line_prime) +
-                       yaffs_count_bits(delta_col)) == 1) {
+       if ((yaffs_count_bits32(delta_line) +
+            yaffs_count_bits32(delta_line_prime) +
+            yaffs_count_bits(delta_col)) == 1) {
                /* Reccoverable error in ecc */
 
                *read_ecc = *test_ecc;
-               return 1; /* corrected */
+               return 1;       /* corrected */
        }
 
        /* Unrecoverable error */
index f505ab5..b0c461d 100644 (file)
 #ifndef __YAFFS_ECC_H__
 #define __YAFFS_ECC_H__
 
-typedef struct {
+struct yaffs_ecc_other {
        unsigned char col_parity;
        unsigned line_parity;
        unsigned line_parity_prime;
-} yaffs_ecc_other;
+};
 
 void yaffs_ecc_cacl(const unsigned char *data, unsigned char *ecc);
 int yaffs_ecc_correct(unsigned char *data, unsigned char *read_ecc,
-               const unsigned char *test_ecc);
+                     const unsigned char *test_ecc);
 
 void yaffs_ecc_calc_other(const unsigned char *data, unsigned n_bytes,
-                       yaffs_ecc_other *ecc);
+                         struct yaffs_ecc_other *ecc);
 int yaffs_ecc_correct_other(unsigned char *data, unsigned n_bytes,
-                       yaffs_ecc_other *read_ecc,
-                       const yaffs_ecc_other *test_ecc);
+                           struct yaffs_ecc_other *read_ecc,
+                           const struct yaffs_ecc_other *test_ecc);
 #endif
index 1c43b6c..108c361 100644 (file)
@@ -20,7 +20,8 @@
 #include "yaffs_trace.h"
 
 /* Function to manipulate block info */
-static Y_INLINE yaffs_block_info_t *yaffs_get_block_info(yaffs_dev_t * dev, int blk)
+static Y_INLINE struct yaffs_block_info *yaffs_get_block_info(struct yaffs_dev
+                                                             *dev, int blk)
 {
        if (blk < dev->internal_start_block || blk > dev->internal_end_block) {
                T(YAFFS_TRACE_ERROR,
index eea828a..a9fc46c 100644 (file)
 #include "yaffs_nameval.h"
 #include "yaffs_allocator.h"
 
+#include "yaffs_attribs.h"
+
 /* Note YAFFS_GC_GOOD_ENOUGH must be <= YAFFS_GC_PASSIVE_THRESHOLD */
 #define YAFFS_GC_GOOD_ENOUGH 2
 #define YAFFS_GC_PASSIVE_THRESHOLD 4
 
 #include "yaffs_ecc.h"
 
-
-
 /* Robustification (if it ever comes about...) */
-static void yaffs_retire_block(yaffs_dev_t *dev, int flash_block);
-static void yaffs_handle_chunk_wr_error(yaffs_dev_t *dev, int nand_chunk,
-               int erased_ok);
-static void yaffs_handle_chunk_wr_ok(yaffs_dev_t *dev, int nand_chunk,
-                               const __u8 *data,
-                               const yaffs_ext_tags *tags);
-static void yaffs_handle_chunk_update(yaffs_dev_t *dev, int nand_chunk,
-                               const yaffs_ext_tags *tags);
+static void yaffs_retire_block(struct yaffs_dev *dev, int flash_block);
+static void yaffs_handle_chunk_wr_error(struct yaffs_dev *dev, int nand_chunk,
+                                       int erased_ok);
+static void yaffs_handle_chunk_wr_ok(struct yaffs_dev *dev, int nand_chunk,
+                                    const u8 * data,
+                                    const struct yaffs_ext_tags *tags);
+static void yaffs_handle_chunk_update(struct yaffs_dev *dev, int nand_chunk,
+                                     const struct yaffs_ext_tags *tags);
 
 /* Other local prototypes */
-static void yaffs_update_parent(yaffs_obj_t *obj);
-static int yaffs_unlink_obj(yaffs_obj_t *obj);
-static int yaffs_obj_cache_dirty(yaffs_obj_t *obj);
-
-static int yaffs_write_new_chunk(yaffs_dev_t *dev,
-                                       const __u8 *buffer,
-                                       yaffs_ext_tags *tags,
-                                       int use_reserver);
-
+static void yaffs_update_parent(struct yaffs_obj *obj);
+static int yaffs_unlink_obj(struct yaffs_obj *obj);
+static int yaffs_obj_cache_dirty(struct yaffs_obj *obj);
 
-static yaffs_obj_t *yaffs_new_obj(yaffs_dev_t *dev, int number,
-                                       yaffs_obj_type type);
+static int yaffs_write_new_chunk(struct yaffs_dev *dev,
+                                const u8 * buffer,
+                                struct yaffs_ext_tags *tags, int use_reserver);
 
+static struct yaffs_obj *yaffs_new_obj(struct yaffs_dev *dev, int number,
+                                      enum yaffs_obj_type type);
 
-static int yaffs_apply_xattrib_mod(yaffs_obj_t *obj, char *buffer, yaffs_xattr_mod *xmod);
+static int yaffs_apply_xattrib_mod(struct yaffs_obj *obj, char *buffer,
+                                  struct yaffs_xattr_mod *xmod);
 
-static void yaffs_remove_obj_from_dir(yaffs_obj_t *obj);
-static int yaffs_check_structures(void);
-static int yaffs_generic_obj_del(yaffs_obj_t *in);
+static void yaffs_remove_obj_from_dir(struct yaffs_obj *obj);
+static int yaffs_generic_obj_del(struct yaffs_obj *in);
 
-static int yaffs_check_chunk_erased(struct yaffs_dev_s *dev,
-                               int nand_chunk);
+static int yaffs_check_chunk_erased(struct yaffs_dev *dev, int nand_chunk);
 
-static int yaffs_unlink_worker(yaffs_obj_t *obj);
+static int yaffs_unlink_worker(struct yaffs_obj *obj);
 
-static int yaffs_tags_match(const yaffs_ext_tags *tags, int obj_id,
-                       int chunk_obj);
+static int yaffs_tags_match(const struct yaffs_ext_tags *tags, int obj_id,
+                           int chunk_obj);
 
-static int yaffs_alloc_chunk(yaffs_dev_t *dev, int use_reserver,
-                               yaffs_block_info_t **block_ptr);
+static int yaffs_alloc_chunk(struct yaffs_dev *dev, int use_reserver,
+                            struct yaffs_block_info **block_ptr);
 
-static void yaffs_check_obj_details_loaded(yaffs_obj_t *in);
+static void yaffs_check_obj_details_loaded(struct yaffs_obj *in);
 
-static void yaffs_invalidate_whole_cache(yaffs_obj_t *in);
-static void yaffs_invalidate_chunk_cache(yaffs_obj_t *object, int chunk_id);
+static void yaffs_invalidate_whole_cache(struct yaffs_obj *in);
+static void yaffs_invalidate_chunk_cache(struct yaffs_obj *object,
+                                        int chunk_id);
 
-static int yaffs_find_chunk_in_file(yaffs_obj_t *in, int inode_chunk,
-                               yaffs_ext_tags *tags);
+static int yaffs_find_chunk_in_file(struct yaffs_obj *in, int inode_chunk,
+                                   struct yaffs_ext_tags *tags);
 
-static int yaffs_verify_chunk_written(yaffs_dev_t *dev,
-                                       int nand_chunk,
-                                       const __u8 *data,
-                                       yaffs_ext_tags *tags);
-
-
-static void yaffs_load_name_from_oh(yaffs_dev_t *dev,YCHAR *name, const YCHAR *oh_name, int buff_size);
-static void yaffs_load_oh_from_name(yaffs_dev_t *dev,YCHAR *oh_name, const YCHAR *name);
+static int yaffs_verify_chunk_written(struct yaffs_dev *dev,
+                                     int nand_chunk,
+                                     const u8 * data,
+                                     struct yaffs_ext_tags *tags);
 
+static void yaffs_load_name_from_oh(struct yaffs_dev *dev, YCHAR * name,
+                                   const YCHAR * oh_name, int buff_size);
+static void yaffs_load_oh_from_name(struct yaffs_dev *dev, YCHAR * oh_name,
+                                   const YCHAR * name);
 
 /* Function to calculate chunk and offset */
 
-static void yaffs_addr_to_chunk(yaffs_dev_t *dev, loff_t addr, int *chunk_out,
-               __u32 *offset_out)
+static void yaffs_addr_to_chunk(struct yaffs_dev *dev, loff_t addr,
+                               int *chunk_out, u32 * offset_out)
 {
        int chunk;
-       __u32 offset;
+       u32 offset;
 
-       chunk  = (__u32)(addr >> dev->chunk_shift);
+       chunk = (u32) (addr >> dev->chunk_shift);
 
        if (dev->chunk_div == 1) {
                /* easy power of 2 case */
-               offset = (__u32)(addr & dev->chunk_mask);
+               offset = (u32) (addr & dev->chunk_mask);
        } else {
                /* Non power-of-2 case */
 
@@ -121,8 +118,8 @@ static void yaffs_addr_to_chunk(yaffs_dev_t *dev, loff_t addr, int *chunk_out,
 
                chunk /= dev->chunk_div;
 
-               chunk_base = ((loff_t)chunk) * dev->data_bytes_per_chunk;
-               offset = (__u32)(addr - chunk_base);
+               chunk_base = ((loff_t) chunk) * dev->data_bytes_per_chunk;
+               offset = (u32) (addr - chunk_base);
        }
 
        *chunk_out = chunk;
@@ -135,7 +132,7 @@ static void yaffs_addr_to_chunk(yaffs_dev_t *dev, loff_t addr, int *chunk_out,
  * be hellishly efficient.
  */
 
-static __u32 calc_shifts_ceiling(__u32 x)
+static u32 calc_shifts_ceiling(u32 x)
 {
        int extra_bits;
        int shifts;
@@ -158,16 +155,16 @@ static __u32 calc_shifts_ceiling(__u32 x)
 /* Function to return the number of shifts to get a 1 in bit 0
  */
 
-static __u32 calc_shifts(__u32 x)
+static u32 calc_shifts(u32 x)
 {
-       __u32 shifts;
+       u32 shifts;
 
-       shifts =  0;
+       shifts = 0;
 
        if (!x)
                return 0;
 
-       while (!(x&1)) {
+       while (!(x & 1)) {
                x >>= 1;
                shifts++;
        }
@@ -175,16 +172,14 @@ static __u32 calc_shifts(__u32 x)
        return shifts;
 }
 
-
-
 /*
  * Temporary buffer manipulations.
  */
 
-static int yaffs_init_tmp_buffers(yaffs_dev_t *dev)
+static int yaffs_init_tmp_buffers(struct yaffs_dev *dev)
 {
        int i;
-       __u8 *buf = (__u8 *)1;
+       u8 *buf = (u8 *) 1;
 
        memset(dev->temp_buffer, 0, sizeof(dev->temp_buffer));
 
@@ -197,7 +192,7 @@ static int yaffs_init_tmp_buffers(yaffs_dev_t *dev)
        return buf ? YAFFS_OK : YAFFS_FAIL;
 }
 
-__u8 *yaffs_get_temp_buffer(yaffs_dev_t *dev, int line_no)
+u8 *yaffs_get_temp_buffer(struct yaffs_dev * dev, int line_no)
 {
        int i, j;
 
@@ -223,7 +218,8 @@ __u8 *yaffs_get_temp_buffer(yaffs_dev_t *dev, int line_no)
          (TSTR("Out of temp buffers at line %d, other held by lines:"),
           line_no));
        for (i = 0; i < YAFFS_N_TEMP_BUFFERS; i++)
-               T(YAFFS_TRACE_BUFFERS, (TSTR(" %d "), dev->temp_buffer[i].line));
+               T(YAFFS_TRACE_BUFFERS,
+                 (TSTR(" %d "), dev->temp_buffer[i].line));
 
        T(YAFFS_TRACE_BUFFERS, (TSTR(" " TENDSTR)));
 
@@ -237,8 +233,7 @@ __u8 *yaffs_get_temp_buffer(yaffs_dev_t *dev, int line_no)
 
 }
 
-void yaffs_release_temp_buffer(yaffs_dev_t *dev, __u8 *buffer,
-                                   int line_no)
+void yaffs_release_temp_buffer(struct yaffs_dev *dev, u8 * buffer, int line_no)
 {
        int i;
 
@@ -265,7 +260,7 @@ void yaffs_release_temp_buffer(yaffs_dev_t *dev, __u8 *buffer,
 /*
  * Determine if we have a managed buffer.
  */
-int yaffs_is_managed_tmp_buffer(yaffs_dev_t *dev, const __u8 *buffer)
+int yaffs_is_managed_tmp_buffer(struct yaffs_dev *dev, const u8 * buffer)
 {
        int i;
 
@@ -283,7 +278,7 @@ int yaffs_is_managed_tmp_buffer(yaffs_dev_t *dev, const __u8 *buffer)
                return 1;
 
        T(YAFFS_TRACE_ALWAYS,
-               (TSTR("yaffs: unmaged buffer detected.\n" TENDSTR)));
+         (TSTR("yaffs: unmaged buffer detected.\n" TENDSTR)));
        return 0;
 }
 
@@ -291,9 +286,6 @@ int yaffs_is_managed_tmp_buffer(yaffs_dev_t *dev, const __u8 *buffer)
  * Verification code
  */
 
-
-
-
 /*
  *  Simple hash function. Needs to have a reasonable spread
  */
@@ -309,22 +301,21 @@ static Y_INLINE int yaffs_hash_fn(int n)
  * Note that root might have a presence in NAND if permissions are set.
  */
 
-yaffs_obj_t *yaffs_root(yaffs_dev_t *dev)
+struct yaffs_obj *yaffs_root(struct yaffs_dev *dev)
 {
        return dev->root_dir;
 }
 
-yaffs_obj_t *yaffs_lost_n_found(yaffs_dev_t *dev)
+struct yaffs_obj *yaffs_lost_n_found(struct yaffs_dev *dev)
 {
        return dev->lost_n_found;
 }
 
-
 /*
  *  Erased NAND checking functions
  */
 
-int yaffs_check_ff(__u8 *buffer, int n_bytes)
+int yaffs_check_ff(u8 * buffer, int n_bytes)
 {
        /* Horrible, slow implementation */
        while (n_bytes--) {
@@ -335,12 +326,11 @@ int yaffs_check_ff(__u8 *buffer, int n_bytes)
        return 1;
 }
 
-static int yaffs_check_chunk_erased(struct yaffs_dev_s *dev,
-                               int nand_chunk)
+static int yaffs_check_chunk_erased(struct yaffs_dev *dev, int nand_chunk)
 {
        int retval = YAFFS_OK;
-       __u8 *data = yaffs_get_temp_buffer(dev, __LINE__);
-       yaffs_ext_tags tags;
+       u8 *data = yaffs_get_temp_buffer(dev, __LINE__);
+       struct yaffs_ext_tags tags;
        int result;
 
        result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, data, &tags);
@@ -360,22 +350,21 @@ static int yaffs_check_chunk_erased(struct yaffs_dev_s *dev,
 
 }
 
-
-static int yaffs_verify_chunk_written(yaffs_dev_t *dev,
-                                       int nand_chunk,
-                                       const __u8 *data,
-                                       yaffs_ext_tags *tags)
+static int yaffs_verify_chunk_written(struct yaffs_dev *dev,
+                                     int nand_chunk,
+                                     const u8 * data,
+                                     struct yaffs_ext_tags *tags)
 {
        int retval = YAFFS_OK;
-       yaffs_ext_tags temp_tags;
-       __u8 *buffer = yaffs_get_temp_buffer(dev,__LINE__);
+       struct yaffs_ext_tags temp_tags;
+       u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
        int result;
-       
-       result = yaffs_rd_chunk_tags_nand(dev,nand_chunk,buffer,&temp_tags);
-       if(memcmp(buffer,data,dev->data_bytes_per_chunk) ||
-               temp_tags.obj_id != tags->obj_id ||
-               temp_tags.chunk_id  != tags->chunk_id ||
-               temp_tags.n_bytes != tags->n_bytes)
+
+       result = yaffs_rd_chunk_tags_nand(dev, nand_chunk, buffer, &temp_tags);
+       if (memcmp(buffer, data, dev->data_bytes_per_chunk) ||
+           temp_tags.obj_id != tags->obj_id ||
+           temp_tags.chunk_id != tags->chunk_id ||
+           temp_tags.n_bytes != tags->n_bytes)
                retval = YAFFS_FAIL;
 
        yaffs_release_temp_buffer(dev, buffer, __LINE__);
@@ -383,10 +372,9 @@ static int yaffs_verify_chunk_written(yaffs_dev_t *dev,
        return retval;
 }
 
-static int yaffs_write_new_chunk(struct yaffs_dev_s *dev,
-                                       const __u8 *data,
-                                       yaffs_ext_tags *tags,
-                                       int use_reserver)
+static int yaffs_write_new_chunk(struct yaffs_dev *dev,
+                                const u8 * data,
+                                struct yaffs_ext_tags *tags, int use_reserver)
 {
        int attempts = 0;
        int write_ok = 0;
@@ -395,7 +383,7 @@ static int yaffs_write_new_chunk(struct yaffs_dev_s *dev,
        yaffs2_checkpt_invalidate(dev);
 
        do {
-               yaffs_block_info_t *bi = 0;
+               struct yaffs_block_info *bi = 0;
                int erased_ok = 0;
 
                chunk = yaffs_alloc_chunk(dev, use_reserver, &bi);
@@ -410,7 +398,7 @@ static int yaffs_write_new_chunk(struct yaffs_dev_s *dev,
                 *
                 * Check the first page we try to write in a block.
                 * If the check passes then we don't need to check any
-                * more.        If the check fails, we check again...
+                * more.        If the check fails, we check again...
                 * If the block has been erased, we don't need to check.
                 *
                 * However, if the block has been prioritised for gc,
@@ -431,30 +419,30 @@ static int yaffs_write_new_chunk(struct yaffs_dev_s *dev,
                /* let's give it a try */
                attempts++;
 
-               if(dev->param.always_check_erased)
+               if (dev->param.always_check_erased)
                        bi->skip_erased_check = 0;
 
                if (!bi->skip_erased_check) {
                        erased_ok = yaffs_check_chunk_erased(dev, chunk);
                        if (erased_ok != YAFFS_OK) {
                                T(YAFFS_TRACE_ERROR,
-                               (TSTR("**>> yaffs chunk %d was not erased"
-                               TENDSTR), chunk));
+                                 (TSTR("**>> yaffs chunk %d was not erased"
+                                       TENDSTR), chunk));
 
                                /* If not erased, delete this one,
                                 * skip rest of block and
                                 * try another chunk */
-                                yaffs_chunk_del(dev,chunk,1,__LINE__);
-                                yaffs_skip_rest_of_block(dev);
+                               yaffs_chunk_del(dev, chunk, 1, __LINE__);
+                               yaffs_skip_rest_of_block(dev);
                                continue;
                        }
                }
 
-               write_ok = yaffs_wr_chunk_tags_nand(dev, chunk,
-                               data, tags);
+               write_ok = yaffs_wr_chunk_tags_nand(dev, chunk, data, tags);
 
-               if(!bi->skip_erased_check)
-                       write_ok = yaffs_verify_chunk_written(dev, chunk, data, tags);
+               if (!bi->skip_erased_check)
+                       write_ok =
+                           yaffs_verify_chunk_written(dev, chunk, data, tags);
 
                if (write_ok != YAFFS_OK) {
                        /* Clean up aborted write, skip to next block and
@@ -469,15 +457,15 @@ static int yaffs_write_new_chunk(struct yaffs_dev_s *dev,
                yaffs_handle_chunk_wr_ok(dev, chunk, data, tags);
 
        } while (write_ok != YAFFS_OK &&
-               (yaffs_wr_attempts <= 0 || attempts <= yaffs_wr_attempts));
+                (yaffs_wr_attempts <= 0 || attempts <= yaffs_wr_attempts));
 
        if (!write_ok)
                chunk = -1;
 
        if (attempts > 1) {
                T(YAFFS_TRACE_ERROR,
-                       (TSTR("**>> yaffs write required %d attempts" TENDSTR),
-                       attempts));
+                 (TSTR("**>> yaffs write required %d attempts" TENDSTR),
+                  attempts));
 
                dev->n_retired_writes += (attempts - 1);
        }
@@ -485,39 +473,43 @@ static int yaffs_write_new_chunk(struct yaffs_dev_s *dev,
        return chunk;
 }
 
-
 /*
  * Block retiring for handling a broken block.
  */
 
-static void yaffs_retire_block(yaffs_dev_t *dev, int flash_block)
+static void yaffs_retire_block(struct yaffs_dev *dev, int flash_block)
 {
-       yaffs_block_info_t *bi = yaffs_get_block_info(dev, flash_block);
+       struct yaffs_block_info *bi = yaffs_get_block_info(dev, flash_block);
 
        yaffs2_checkpt_invalidate(dev);
-       
-       yaffs2_clear_oldest_dirty_seq(dev,bi);
+
+       yaffs2_clear_oldest_dirty_seq(dev, bi);
 
        if (yaffs_mark_bad(dev, flash_block) != YAFFS_OK) {
                if (yaffs_erase_block(dev, flash_block) != YAFFS_OK) {
-                       T(YAFFS_TRACE_ALWAYS, (TSTR(
-                               "yaffs: Failed to mark bad and erase block %d"
-                               TENDSTR), flash_block));
+                       T(YAFFS_TRACE_ALWAYS,
+                         (TSTR
+                          ("yaffs: Failed to mark bad and erase block %d"
+                           TENDSTR), flash_block));
                } else {
-                       yaffs_ext_tags tags;
-                       int chunk_id = flash_block * dev->param.chunks_per_block;
+                       struct yaffs_ext_tags tags;
+                       int chunk_id =
+                           flash_block * dev->param.chunks_per_block;
 
-                       __u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
+                       u8 *buffer = yaffs_get_temp_buffer(dev, __LINE__);
 
                        memset(buffer, 0xff, dev->data_bytes_per_chunk);
                        yaffs_init_tags(&tags);
                        tags.seq_number = YAFFS_SEQUENCE_BAD_BLOCK;
                        if (dev->param.write_chunk_tags_fn(dev, chunk_id -
-                               dev->chunk_offset, buffer, &tags) != YAFFS_OK)
-                               T(YAFFS_TRACE_ALWAYS, (TSTR("yaffs: Failed to "
-                                       TCONT("write bad block marker to block %d")
-                                       TENDSTR), flash_block));
+                                                          dev->chunk_offset,
+                                                          buffer,
+                                                          &tags) != YAFFS_OK)
+                               T(YAFFS_TRACE_ALWAYS,
+                                 (TSTR
+                                  ("yaffs: Failed to "
+                                   TCONT("write bad block marker to block %d")
+                                   TENDSTR), flash_block));
 
                        yaffs_release_temp_buffer(dev, buffer, __LINE__);
                }
@@ -535,25 +527,26 @@ static void yaffs_retire_block(yaffs_dev_t *dev, int flash_block)
  *
  */
 
-static void yaffs_handle_chunk_wr_ok(yaffs_dev_t *dev, int nand_chunk,
-                               const __u8 *data,
-                               const yaffs_ext_tags *tags)
+static void yaffs_handle_chunk_wr_ok(struct yaffs_dev *dev, int nand_chunk,
+                                    const u8 * data,
+                                    const struct yaffs_ext_tags *tags)
 {
-       dev=dev;
-       nand_chunk=nand_chunk;
-       data=data;
-       tags=tags;
+       dev = dev;
+       nand_chunk = nand_chunk;
+       data = data;
+       tags = tags;
 }
 
-static void yaffs_handle_chunk_update(yaffs_dev_t *dev, int nand_chunk,
-                               const yaffs_ext_tags *tags)
+static void yaffs_handle_chunk_update(struct yaffs_dev *dev, int nand_chunk,
+                                     const struct yaffs_ext_tags *tags)
 {
-       dev=dev;
-       nand_chunk=nand_chunk;
-       tags=tags;
+       dev = dev;
+       nand_chunk = nand_chunk;
+       tags = tags;
 }
 
-void yaffs_handle_chunk_error(yaffs_dev_t *dev, yaffs_block_info_t *bi)
+void yaffs_handle_chunk_error(struct yaffs_dev *dev,
+                             struct yaffs_block_info *bi)
 {
        if (!bi->gc_prioritise) {
                bi->gc_prioritise = 1;
@@ -561,18 +554,19 @@ void yaffs_handle_chunk_error(yaffs_dev_t *dev, yaffs_block_info_t *bi)
                bi->chunk_error_strikes++;
 
                if (bi->chunk_error_strikes > 3) {
-                       bi->needs_retiring = 1; /* Too many stikes, so retire this */
-                       T(YAFFS_TRACE_ALWAYS, (TSTR("yaffs: Block struck out" TENDSTR)));
+                       bi->needs_retiring = 1; /* Too many stikes, so retire this */
+                       T(YAFFS_TRACE_ALWAYS,
+                         (TSTR("yaffs: Block struck out" TENDSTR)));
 
                }
        }
 }
 
-static void yaffs_handle_chunk_wr_error(yaffs_dev_t *dev, int nand_chunk,
-               int erased_ok)
+static void yaffs_handle_chunk_wr_error(struct yaffs_dev *dev, int nand_chunk,
+                                       int erased_ok)
 {
        int flash_block = nand_chunk / dev->param.chunks_per_block;
-       yaffs_block_info_t *bi = yaffs_get_block_info(dev, flash_block);
+       struct yaffs_block_info *bi = yaffs_get_block_info(dev, flash_block);
 
        yaffs_handle_chunk_error(dev, bi);
 
@@ -588,23 +582,19 @@ static void yaffs_handle_chunk_wr_error(yaffs_dev_t *dev, int nand_chunk,
        yaffs_skip_rest_of_block(dev);
 }
 
-
 /*---------------- Name handling functions ------------*/
 
-static __u16 yaffs_calc_name_sum(const YCHAR *name)
+static u16 yaffs_calc_name_sum(const YCHAR * name)
 {
-       __u16 sum = 0;
-       __u16 i = 1;
+       u16 sum = 0;
+       u16 i = 1;
 
-       const YUCHAR *bname = (const YUCHAR *) name;
+       const YUCHAR *bname = (const YUCHAR *)name;
        if (bname) {
-               while ((*bname) && (i < (YAFFS_MAX_NAME_LENGTH/2))) {
+               while ((*bname) && (i < (YAFFS_MAX_NAME_LENGTH / 2))) {
 
-#ifdef CONFIG_YAFFS_CASE_INSENSITIVE
-                       sum += yaffs_toupper(*bname) * i;
-#else
-                       sum += (*bname) * i;
-#endif
+                       /* 0x1f mask is case insensitive */
+                       sum += ((*bname) & 0x1f) * i;
                        i++;
                        bname++;
                }
@@ -612,11 +602,15 @@ static __u16 yaffs_calc_name_sum(const YCHAR *name)
        return sum;
 }
 
-void yaffs_set_obj_name(yaffs_obj_t *obj, const YCHAR *name)
+void yaffs_set_obj_name(struct yaffs_obj *obj, const YCHAR * name)
 {
 #ifdef CONFIG_YAFFS_SHORT_NAMES_IN_RAM
-       memset(obj->short_name, 0, sizeof(YCHAR) * (YAFFS_SHORT_NAME_LENGTH+1));
-       if (name && yaffs_strnlen(name,YAFFS_SHORT_NAME_LENGTH+1) <= YAFFS_SHORT_NAME_LENGTH)
+       memset(obj->short_name, 0,
+              sizeof(YCHAR) * (YAFFS_SHORT_NAME_LENGTH + 1));
+       if (name
+           && yaffs_strnlen(name,
+                            YAFFS_SHORT_NAME_LENGTH + 1) <=
+           YAFFS_SHORT_NAME_LENGTH)
                yaffs_strcpy(obj->short_name, name);
        else
                obj->short_name[0] = _Y('\0');
@@ -624,15 +618,17 @@ void yaffs_set_obj_name(yaffs_obj_t *obj, const YCHAR *name)
        obj->sum = yaffs_calc_name_sum(name);
 }
 
-void yaffs_set_obj_name_from_oh(yaffs_obj_t *obj, const yaffs_obj_header *oh)
+void yaffs_set_obj_name_from_oh(struct yaffs_obj *obj,
+                               const struct yaffs_obj_hdr *oh)
 {
 #ifdef CONFIG_YAFFS_AUTO_UNICODE
-       YCHAR tmp_name[YAFFS_MAX_NAME_LENGTH+1];
-       memset(tmp_name,0,sizeof(tmp_name));
-       yaffs_load_name_from_oh(obj->my_dev,tmp_name,oh->name,YAFFS_MAX_NAME_LENGTH+1);
-       yaffs_set_obj_name(obj,tmp_name);
+       YCHAR tmp_name[YAFFS_MAX_NAME_LENGTH + 1];
+       memset(tmp_name, 0, sizeof(tmp_name));
+       yaffs_load_name_from_oh(obj->my_dev, tmp_name, oh->name,
+                               YAFFS_MAX_NAME_LENGTH + 1);
+       yaffs_set_obj_name(obj, tmp_name);
 #else
-       yaffs_set_obj_name(obj,oh->name);
+       yaffs_set_obj_name(obj, oh->name);
 #endif
 }
 
@@ -643,44 +639,42 @@ void yaffs_set_obj_name_from_oh(yaffs_obj_t *obj, const yaffs_obj_header *oh)
  * in the tnode.
  */
 
-
-yaffs_tnode_t *yaffs_get_tnode(yaffs_dev_t *dev)
+struct yaffs_tnode *yaffs_get_tnode(struct yaffs_dev *dev)
 {
-       yaffs_tnode_t *tn = yaffs_alloc_raw_tnode(dev);
-       if (tn){
+       struct yaffs_tnode *tn = yaffs_alloc_raw_tnode(dev);
+       if (tn) {
                memset(tn, 0, dev->tnode_size);
                dev->n_tnodes++;
        }
 
-       dev->checkpoint_blocks_required = 0; /* force recalculation*/
+       dev->checkpoint_blocks_required = 0;    /* force recalculation */
 
        return tn;
 }
 
 /* FreeTnode frees up a tnode and puts it back on the free list */
-static void yaffs_free_tnode(yaffs_dev_t *dev, yaffs_tnode_t *tn)
+static void yaffs_free_tnode(struct yaffs_dev *dev, struct yaffs_tnode *tn)
 {
-       yaffs_free_raw_tnode(dev,tn);
+       yaffs_free_raw_tnode(dev, tn);
        dev->n_tnodes--;
-       dev->checkpoint_blocks_required = 0; /* force recalculation*/
+       dev->checkpoint_blocks_required = 0;    /* force recalculation */
 }
 
-static void yaffs_deinit_tnodes_and_objs(yaffs_dev_t *dev)
+static void yaffs_deinit_tnodes_and_objs(struct yaffs_dev *dev)
 {
        yaffs_deinit_raw_tnodes_and_objs(dev);
        dev->n_obj = 0;
        dev->n_tnodes = 0;
 }
 
-
-void yaffs_load_tnode_0(yaffs_dev_t *dev, yaffs_tnode_t *tn, unsigned pos,
-               unsigned val)
+void yaffs_load_tnode_0(struct yaffs_dev *dev, struct yaffs_tnode *tn,
+                       unsigned pos, unsigned val)
 {
-       __u32 *map = (__u32 *)tn;
-       __u32 bit_in_map;
-       __u32 bit_in_word;
-       __u32 word_in_map;
-       __u32 mask;
+       u32 *map = (u32 *) tn;
+       u32 bit_in_map;
+       u32 bit_in_word;
+       u32 word_in_map;
+       u32 mask;
 
        pos &= YAFFS_TNODES_LEVEL0_MASK;
        val >>= dev->chunk_grp_bits;
@@ -697,20 +691,21 @@ void yaffs_load_tnode_0(yaffs_dev_t *dev, yaffs_tnode_t *tn, unsigned pos,
        if (dev->tnode_width > (32 - bit_in_word)) {
                bit_in_word = (32 - bit_in_word);
                word_in_map++;;
-               mask = dev->tnode_mask >> (/*dev->tnode_width -*/ bit_in_word);
+               mask =
+                   dev->tnode_mask >> ( /*dev->tnode_width - */ bit_in_word);
                map[word_in_map] &= ~mask;
                map[word_in_map] |= (mask & (val >> bit_in_word));
        }
 }
 
-__u32 yaffs_get_group_base(yaffs_dev_t *dev, yaffs_tnode_t *tn,
-               unsigned pos)
+u32 yaffs_get_group_base(struct yaffs_dev *dev, struct yaffs_tnode *tn,
+                        unsigned pos)
 {
-       __u32 *map = (__u32 *)tn;
-       __u32 bit_in_map;
-       __u32 bit_in_word;
-       __u32 word_in_map;
-       __u32 val;
+       u32 *map = (u32 *) tn;
+       u32 bit_in_map;
+       u32 bit_in_word;
+       u32 word_in_map;
+       u32 val;
 
        pos &= YAFFS_TNODES_LEVEL0_MASK;
 
@@ -720,7 +715,7 @@ __u32 yaffs_get_group_base(yaffs_dev_t *dev, yaffs_tnode_t *tn,
 
        val = map[word_in_map] >> bit_in_word;
 
-       if      (dev->tnode_width > (32 - bit_in_word)) {
+       if (dev->tnode_width > (32 - bit_in_word)) {
                bit_in_word = (32 - bit_in_word);
                word_in_map++;;
                val |= (map[word_in_map] << bit_in_word);
@@ -740,16 +735,16 @@ __u32 yaffs_get_group_base(yaffs_dev_t *dev, yaffs_tnode_t *tn,
  */
 
 /* FindLevel0Tnode finds the level 0 tnode, if one exists. */
-yaffs_tnode_t *yaffs_find_tnode_0(yaffs_dev_t *dev,
-                                       yaffs_file_s *file_struct,
-                                       __u32 chunk_id)
+struct yaffs_tnode *yaffs_find_tnode_0(struct yaffs_dev *dev,
+                                      struct yaffs_file_var *file_struct,
+                                      u32 chunk_id)
 {
-       yaffs_tnode_t *tn = file_struct->top;
-       __u32 i;
+       struct yaffs_tnode *tn = file_struct->top;
+       u32 i;
        int required_depth;
        int level = file_struct->top_level;
 
-       dev=dev;
+       dev = dev;
 
        /* Check sane level and chunk Id */
        if (level < 0 || level > YAFFS_TNODES_MAX_LEVEL)
@@ -768,15 +763,15 @@ yaffs_tnode_t *yaffs_find_tnode_0(yaffs_dev_t *dev,
        }
 
        if (required_depth > file_struct->top_level)
-               return NULL; /* Not tall enough, so we can't find it */
+               return NULL;    /* Not tall enough, so we can't find it */
 
        /* Traverse down to level 0 */
        while (level > 0 && tn) {
                tn = tn->internal[(chunk_id >>
-                       (YAFFS_TNODES_LEVEL0_BITS +
-                               (level - 1) *
-                               YAFFS_TNODES_INTERNAL_BITS)) &
-                       YAFFS_TNODES_INTERNAL_MASK];
+                                  (YAFFS_TNODES_LEVEL0_BITS +
+                                   (level - 1) *
+                                   YAFFS_TNODES_INTERNAL_BITS)) &
+                                 YAFFS_TNODES_INTERNAL_MASK];
                level--;
        }
 
@@ -794,21 +789,21 @@ yaffs_tnode_t *yaffs_find_tnode_0(yaffs_dev_t *dev,
  *  be plugged into the ttree.
  */
 
-yaffs_tnode_t *yaffs_add_find_tnode_0(yaffs_dev_t *dev,
-                                       yaffs_file_s *file_struct,
-                                       __u32 chunk_id,
-                                       yaffs_tnode_t *passed_tn)
+struct yaffs_tnode *yaffs_add_find_tnode_0(struct yaffs_dev *dev,
+                                          struct yaffs_file_var *file_struct,
+                                          u32 chunk_id,
+                                          struct yaffs_tnode *passed_tn)
 {
        int required_depth;
        int i;
        int l;
-       yaffs_tnode_t *tn;
-
-       __u32 x;
+       struct yaffs_tnode *tn;
 
+       u32 x;
 
        /* Check sane level and page Id */
-       if (file_struct->top_level < 0 || file_struct->top_level > YAFFS_TNODES_MAX_LEVEL)
+       if (file_struct->top_level < 0
+           || file_struct->top_level > YAFFS_TNODES_MAX_LEVEL)
                return NULL;
 
        if (chunk_id > YAFFS_MAX_CHUNK_ID)
@@ -823,7 +818,6 @@ yaffs_tnode_t *yaffs_add_find_tnode_0(yaffs_dev_t *dev,
                required_depth++;
        }
 
-
        if (required_depth > file_struct->top_level) {
                /* Not tall enough, gotta make the tree taller */
                for (i = file_struct->top_level; i < required_depth; i++) {
@@ -836,7 +830,7 @@ yaffs_tnode_t *yaffs_add_find_tnode_0(yaffs_dev_t *dev,
                                file_struct->top_level++;
                        } else {
                                T(YAFFS_TRACE_ERROR,
-                                       (TSTR("yaffs: no more tnodes" TENDSTR)));
+                                 (TSTR("yaffs: no more tnodes" TENDSTR)));
                                return NULL;
                        }
                }
@@ -854,24 +848,25 @@ yaffs_tnode_t *yaffs_add_find_tnode_0(yaffs_dev_t *dev,
                              (l - 1) * YAFFS_TNODES_INTERNAL_BITS)) &
                            YAFFS_TNODES_INTERNAL_MASK;
 
-
                        if ((l > 1) && !tn->internal[x]) {
                                /* Add missing non-level-zero tnode */
                                tn->internal[x] = yaffs_get_tnode(dev);
-                               if(!tn->internal[x])
+                               if (!tn->internal[x])
                                        return NULL;
                        } else if (l == 1) {
                                /* Looking from level 1 at level 0 */
                                if (passed_tn) {
-                                       /* If we already have one, then release it.*/
+                                       /* If we already have one, then release it. */
                                        if (tn->internal[x])
-                                               yaffs_free_tnode(dev, tn->internal[x]);
+                                               yaffs_free_tnode(dev,
+                                                                tn->
+                                                                internal[x]);
                                        tn->internal[x] = passed_tn;
 
                                } else if (!tn->internal[x]) {
                                        /* Don't have one, none passed in */
                                        tn->internal[x] = yaffs_get_tnode(dev);
-                                       if(!tn->internal[x])
+                                       if (!tn->internal[x])
                                                return NULL;
                                }
                        }
@@ -882,7 +877,8 @@ yaffs_tnode_t *yaffs_add_find_tnode_0(yaffs_dev_t *dev,
        } else {
                /* top is level 0 */
                if (passed_tn) {
-                       memcpy(tn, passed_tn, (dev->tnode_width * YAFFS_NTNODES_LEVEL0)/8);
+                       memcpy(tn, passed_tn,
+                              (dev->tnode_width * YAFFS_NTNODES_LEVEL0) / 8);
                        yaffs_free_tnode(dev, passed_tn);
                }
        }
@@ -890,21 +886,22 @@ yaffs_tnode_t *yaffs_add_find_tnode_0(yaffs_dev_t *dev,
        return tn;
 }
 
-static int yaffs_find_chunk_in_group(yaffs_dev_t *dev, int the_chunk,
-                               yaffs_ext_tags *tags, int obj_id,
-                               int inode_chunk)
+static int yaffs_find_chunk_in_group(struct yaffs_dev *dev, int the_chunk,
+                                    struct yaffs_ext_tags *tags, int obj_id,
+                                    int inode_chunk)
 {
        int j;
 
        for (j = 0; the_chunk && j < dev->chunk_grp_size; j++) {
-               if (yaffs_check_chunk_bit(dev, the_chunk / dev->param.chunks_per_block,
-                               the_chunk % dev->param.chunks_per_block)) {
-                       
-                       if(dev->chunk_grp_size == 1)
+               if (yaffs_check_chunk_bit
+                   (dev, the_chunk / dev->param.chunks_per_block,
+                    the_chunk % dev->param.chunks_per_block)) {
+
+                       if (dev->chunk_grp_size == 1)
                                return the_chunk;
                        else {
                                yaffs_rd_chunk_tags_nand(dev, the_chunk, NULL,
-                                                               tags);
+                                                        tags);
                                if (yaffs_tags_match(tags, obj_id, inode_chunk)) {
                                        /* found it; */
                                        return the_chunk;
@@ -916,111 +913,14 @@ static int yaffs_find_chunk_in_group(yaffs_dev_t *dev, int the_chunk,
        return -1;
 }
 
-#if 0
-/* Experimental code not being used yet. Might speed up file deletion */
-/* DeleteWorker scans backwards through the tnode tree and deletes all the
- * chunks and tnodes in the file.
- * Returns 1 if the tree was deleted.
- * Returns 0 if it stopped early due to hitting the limit and the delete is incomplete.
- */
-
-static int yaffs_del_worker(yaffs_obj_t *in, yaffs_tnode_t *tn, __u32 level,
-                             int chunk_offset, int *limit)
+static void yaffs_soft_del_chunk(struct yaffs_dev *dev, int chunk)
 {
-       int i;
-       int inode_chunk;
-       int the_chunk;
-       yaffs_ext_tags tags;
-       int found_chunk;
-       yaffs_dev_t *dev = in->my_dev;
-
-       int all_done = 1;
-
-       if (tn) {
-               if (level > 0) {
-                       for (i = YAFFS_NTNODES_INTERNAL - 1; all_done && i >= 0;
-                            i--) {
-                               if (tn->internal[i]) {
-                                       if (limit && (*limit) < 0) {
-                                               all_done = 0;
-                                       } else {
-                                               all_done =
-                                                       yaffs_del_worker(in,
-                                                               tn->
-                                                               internal
-                                                               [i],
-                                                               level -
-                                                               1,
-                                                               (chunk_offset
-                                                                       <<
-                                                                       YAFFS_TNODES_INTERNAL_BITS)
-                                                               + i,
-                                                               limit);
-                                       }
-                                       if (all_done) {
-                                               yaffs_free_tnode(dev,
-                                                               tn->
-                                                               internal[i]);
-                                               tn->internal[i] = NULL;
-                                       }
-                               }
-                       }
-                       return (all_done) ? 1 : 0;
-               } else if (level == 0) {
-                       int hit_limit = 0;
-
-                       for (i = YAFFS_NTNODES_LEVEL0 - 1; i >= 0 && !hit_limit;
-                                       i--) {
-                               the_chunk = yaffs_get_group_base(dev, tn, i);
-                               if (the_chunk) {
-
-                                       inode_chunk = (chunk_offset <<
-                                               YAFFS_TNODES_LEVEL0_BITS) + i;
-
-                                       found_chunk =
-                                               yaffs_find_chunk_in_group(dev,
-                                                               the_chunk,
-                                                               &tags,
-                                                               in->obj_id,
-                                                               inode_chunk);
-
-                                       if (found_chunk > 0) {
-                                               yaffs_chunk_del(dev,
-                                                                 found_chunk, 1,
-                                                                 __LINE__);
-                                               in->n_data_chunks--;
-                                               if (limit) {
-                                                       *limit = *limit - 1;
-                                                       if (*limit <= 0)
-                                                               hit_limit = 1;
-                                               }
-
-                                       }
-
-                                       yaffs_load_tnode_0(dev, tn, i, 0);
-                               }
-
-                       }
-                       return (i < 0) ? 1 : 0;
-
-               }
-
-       }
-
-       return 1;
-
-}
-
-#endif
-
-static void yaffs_soft_del_chunk(yaffs_dev_t *dev, int chunk)
-{
-       yaffs_block_info_t *the_block;
+       struct yaffs_block_info *the_block;
        unsigned block_no;
 
        T(YAFFS_TRACE_DELETION, (TSTR("soft delete chunk %d" TENDSTR), chunk));
 
-       block_no =  chunk / dev->param.chunks_per_block;
+       block_no = chunk / dev->param.chunks_per_block;
        the_block = yaffs_get_block_info(dev, block_no);
        if (the_block) {
                the_block->soft_del_pages++;
@@ -1035,13 +935,13 @@ static void yaffs_soft_del_chunk(yaffs_dev_t *dev, int chunk)
  * Thus, essentially this is the same as DeleteWorker except that the chunks are soft deleted.
  */
 
-static int yaffs_soft_del_worker(yaffs_obj_t *in, yaffs_tnode_t *tn,
-                                 __u32 level, int chunk_offset)
+static int yaffs_soft_del_worker(struct yaffs_obj *in, struct yaffs_tnode *tn,
+                                u32 level, int chunk_offset)
 {
        int i;
        int the_chunk;
        int all_done = 1;
-       yaffs_dev_t *dev = in->my_dev;
+       struct yaffs_dev *dev = in->my_dev;
 
        if (tn) {
                if (level > 0) {
@@ -1051,17 +951,17 @@ static int yaffs_soft_del_worker(yaffs_obj_t *in, yaffs_tnode_t *tn,
                                if (tn->internal[i]) {
                                        all_done =
                                            yaffs_soft_del_worker(in,
-                                                                  tn->
-                                                                  internal[i],
-                                                                  level - 1,
-                                                                  (chunk_offset
-                                                                   <<
-                                                                   YAFFS_TNODES_INTERNAL_BITS)
-                                                                  + i);
+                                                                 tn->internal
+                                                                 [i],
+                                                                 level - 1,
+                                                                 (chunk_offset
+                                                                  <<
+                                                                  YAFFS_TNODES_INTERNAL_BITS)
+                                                                 + i);
                                        if (all_done) {
                                                yaffs_free_tnode(dev,
-                                                               tn->
-                                                               internal[i]);
+                                                                tn->internal
+                                                                [i]);
                                                tn->internal[i] = NULL;
                                        } else {
                                                /* Hoosterman... how could this happen? */
@@ -1093,14 +993,14 @@ static int yaffs_soft_del_worker(yaffs_obj_t *in, yaffs_tnode_t *tn,
 
 }
 
-static void yaffs_soft_del_file(yaffs_obj_t *obj)
+static void yaffs_soft_del_file(struct yaffs_obj *obj)
 {
        if (obj->deleted &&
            obj->variant_type == YAFFS_OBJECT_TYPE_FILE && !obj->soft_del) {
                if (obj->n_data_chunks <= 0) {
                        /* Empty file with no duplicate object headers, just delete it immediately */
                        yaffs_free_tnode(obj->my_dev,
-                                       obj->variant.file_variant.top);
+                                        obj->variant.file_variant.top);
                        obj->variant.file_variant.top = NULL;
                        T(YAFFS_TRACE_TRACING,
                          (TSTR("yaffs: Deleting empty file %d" TENDSTR),
@@ -1108,9 +1008,9 @@ static void yaffs_soft_del_file(yaffs_obj_t *obj)
                        yaffs_generic_obj_del(obj);
                } else {
                        yaffs_soft_del_worker(obj,
-                                              obj->variant.file_variant.top,
-                                              obj->variant.file_variant.
-                                              top_level, 0);
+                                             obj->variant.file_variant.top,
+                                             obj->variant.
+                                             file_variant.top_level, 0);
                        obj->soft_del = 1;
                }
        }
@@ -1131,8 +1031,9 @@ static void yaffs_soft_del_file(yaffs_obj_t *obj)
  * If there is no data in a subtree then it is pruned.
  */
 
-static yaffs_tnode_t *yaffs_prune_worker(yaffs_dev_t *dev, yaffs_tnode_t *tn,
-                               __u32 level, int del0)
+static struct yaffs_tnode *yaffs_prune_worker(struct yaffs_dev *dev,
+                                             struct yaffs_tnode *tn, u32 level,
+                                             int del0)
 {
        int i;
        int has_data;
@@ -1140,27 +1041,29 @@ static yaffs_tnode_t *yaffs_prune_worker(yaffs_dev_t *dev, yaffs_tnode_t *tn,
        if (tn) {
                has_data = 0;
 
-               if(level > 0){
+               if (level > 0) {
                        for (i = 0; i < YAFFS_NTNODES_INTERNAL; i++) {
                                if (tn->internal[i]) {
                                        tn->internal[i] =
-                                               yaffs_prune_worker(dev, tn->internal[i],
-                                                       level - 1,
-                                                       (i == 0) ? del0 : 1);
+                                           yaffs_prune_worker(dev,
+                                                              tn->internal[i],
+                                                              level - 1,
+                                                              (i ==
+                                                               0) ? del0 : 1);
                                }
 
                                if (tn->internal[i])
                                        has_data++;
                        }
                } else {
-                       int tnode_size_u32 = dev->tnode_size/sizeof(__u32);
-                       __u32 *map = (__u32 *)tn;
+                       int tnode_size_u32 = dev->tnode_size / sizeof(u32);
+                       u32 *map = (u32 *) tn;
 
-                        for(i = 0; !has_data && i < tnode_size_u32; i++){
-                                if(map[i])
-                                        has_data++;
-                        }
-                }
+                       for (i = 0; !has_data && i < tnode_size_u32; i++) {
+                               if (map[i])
+                                       has_data++;
+                       }
+               }
 
                if (has_data == 0 && del0) {
                        /* Free and return NULL */
@@ -1175,17 +1078,18 @@ static yaffs_tnode_t *yaffs_prune_worker(yaffs_dev_t *dev, yaffs_tnode_t *tn,
 
 }
 
-static int yaffs_prune_tree(yaffs_dev_t *dev,
-                               yaffs_file_s *file_struct)
+static int yaffs_prune_tree(struct yaffs_dev *dev,
+                           struct yaffs_file_var *file_struct)
 {
        int i;
        int has_data;
        int done = 0;
-       yaffs_tnode_t *tn;
+       struct yaffs_tnode *tn;
 
        if (file_struct->top_level > 0) {
                file_struct->top =
-                   yaffs_prune_worker(dev, file_struct->top, file_struct->top_level, 0);
+                   yaffs_prune_worker(dev, file_struct->top,
+                                      file_struct->top_level, 0);
 
                /* Now we have a tree with all the non-zero branches NULL but the height
                 * is the same as it was.
@@ -1218,32 +1122,31 @@ static int yaffs_prune_tree(yaffs_dev_t *dev,
 
 /*-------------------- End of File Structure functions.-------------------*/
 
-
 /* AllocateEmptyObject gets us a clean Object. Tries to make allocate more if we run out */
-static yaffs_obj_t *yaffs_alloc_empty_obj(yaffs_dev_t *dev)
+static struct yaffs_obj *yaffs_alloc_empty_obj(struct yaffs_dev *dev)
 {
-       yaffs_obj_t *obj = yaffs_alloc_raw_obj(dev);
+       struct yaffs_obj *obj = yaffs_alloc_raw_obj(dev);
 
        if (obj) {
                dev->n_obj++;
 
                /* Now sweeten it up... */
 
-               memset(obj, 0, sizeof(yaffs_obj_t));
+               memset(obj, 0, sizeof(struct yaffs_obj));
                obj->being_created = 1;
 
                obj->my_dev = dev;
                obj->hdr_chunk = 0;
                obj->variant_type = YAFFS_OBJECT_TYPE_UNKNOWN;
-               YINIT_LIST_HEAD(&(obj->hard_links));
-               YINIT_LIST_HEAD(&(obj->hash_link));
-               YINIT_LIST_HEAD(&obj->siblings);
-
+               INIT_LIST_HEAD(&(obj->hard_links));
+               INIT_LIST_HEAD(&(obj->hash_link));
+               INIT_LIST_HEAD(&obj->siblings);
 
                /* Now make the directory sane */
                if (dev->root_dir) {
                        obj->parent = dev->root_dir;
-                       ylist_add(&(obj->siblings), &dev->root_dir->variant.dir_variant.children);
+                       list_add(&(obj->siblings),
+                                &dev->root_dir->variant.dir_variant.children);
                }
 
                /* Add it to the lost and found directory.
@@ -1256,19 +1159,19 @@ static yaffs_obj_t *yaffs_alloc_empty_obj(yaffs_dev_t *dev)
                obj->being_created = 0;
        }
 
-       dev->checkpoint_blocks_required = 0; /* force recalculation*/
+       dev->checkpoint_blocks_required = 0;    /* force recalculation */
 
        return obj;
 }
 
-static yaffs_obj_t *yaffs_create_fake_dir(yaffs_dev_t *dev, int number,
-                                              __u32 mode)
+static struct yaffs_obj *yaffs_create_fake_dir(struct yaffs_dev *dev,
+                                              int number, u32 mode)
 {
 
-       yaffs_obj_t *obj =
+       struct yaffs_obj *obj =
            yaffs_new_obj(dev, number, YAFFS_OBJECT_TYPE_DIRECTORY);
        if (obj) {
-               obj->fake = 1;          /* it is fake so it might have no NAND presence... */
+               obj->fake = 1;  /* it is fake so it might have no NAND presence... */
                obj->rename_allowed = 0;        /* ... and we're not allowed to rename it... */
                obj->unlink_allowed = 0;        /* ... or unlink it */
                obj->deleted = 0;
@@ -1282,34 +1185,34 @@ static yaffs_obj_t *yaffs_create_fake_dir(yaffs_dev_t *dev, int number,
 
 }
 
-static void yaffs_unhash_obj(yaffs_obj_t *obj)
+static void yaffs_unhash_obj(struct yaffs_obj *obj)
 {
        int bucket;
-       yaffs_dev_t *dev = obj->my_dev;
+       struct yaffs_dev *dev = obj->my_dev;
 
        /* If it is still linked into the bucket list, free from the list */
-       if (!ylist_empty(&obj->hash_link)) {
-               ylist_del_init(&obj->hash_link);
+       if (!list_empty(&obj->hash_link)) {
+               list_del_init(&obj->hash_link);
                bucket = yaffs_hash_fn(obj->obj_id);
                dev->obj_bucket[bucket].count--;
        }
 }
 
 /*  FreeObject frees up a Object and puts it back on the free list */
-static void yaffs_free_obj(yaffs_obj_t *obj)
+static void yaffs_free_obj(struct yaffs_obj *obj)
 {
-       yaffs_dev_t *dev = obj->my_dev;
+       struct yaffs_dev *dev = obj->my_dev;
 
-       T(YAFFS_TRACE_OS, (TSTR("FreeObject %p inode %p"TENDSTR), obj, obj->my_inode));
+       T(YAFFS_TRACE_OS,
+         (TSTR("FreeObject %p inode %p" TENDSTR), obj, obj->my_inode));
 
        if (!obj)
                YBUG();
        if (obj->parent)
                YBUG();
-       if (!ylist_empty(&obj->siblings))
+       if (!list_empty(&obj->siblings))
                YBUG();
 
-
        if (obj->my_inode) {
                /* We're still hooked up to a cached inode.
                 * Don't delete now, but mark for later deletion
@@ -1320,19 +1223,18 @@ static void yaffs_free_obj(yaffs_obj_t *obj)
 
        yaffs_unhash_obj(obj);
 
-       yaffs_free_raw_obj(dev,obj);
+       yaffs_free_raw_obj(dev, obj);
        dev->n_obj--;
-       dev->checkpoint_blocks_required = 0; /* force recalculation*/
+       dev->checkpoint_blocks_required = 0;    /* force recalculation */
 }
 
-
-void yaffs_handle_defered_free(yaffs_obj_t *obj)
+void yaffs_handle_defered_free(struct yaffs_obj *obj)
 {
        if (obj->defered_free)
                yaffs_free_obj(obj);
 }
 
-static void yaffs_init_tnodes_and_objs(yaffs_dev_t *dev)
+static void yaffs_init_tnodes_and_objs(struct yaffs_dev *dev)
 {
        int i;
 
@@ -1342,18 +1244,17 @@ static void yaffs_init_tnodes_and_objs(yaffs_dev_t *dev)
        yaffs_init_raw_tnodes_and_objs(dev);
 
        for (i = 0; i < YAFFS_NOBJECT_BUCKETS; i++) {
-               YINIT_LIST_HEAD(&dev->obj_bucket[i].list);
+               INIT_LIST_HEAD(&dev->obj_bucket[i].list);
                dev->obj_bucket[i].count = 0;
        }
 }
 
-static int yaffs_find_nice_bucket(yaffs_dev_t *dev)
+static int yaffs_find_nice_bucket(struct yaffs_dev *dev)
 {
        int i;
        int l = 999;
        int lowest = 999999;
 
-
        /* Search for the shortest list or one that
         * isn't too long.
         */
@@ -1371,7 +1272,7 @@ static int yaffs_find_nice_bucket(yaffs_dev_t *dev)
        return l;
 }
 
-static int yaffs_new_obj_id(yaffs_dev_t *dev)
+static int yaffs_new_obj_id(struct yaffs_dev *dev)
 {
        int bucket = yaffs_find_nice_bucket(dev);
 
@@ -1380,9 +1281,9 @@ static int yaffs_new_obj_id(yaffs_dev_t *dev)
         */
 
        int found = 0;
-       struct ylist_head *i;
+       struct list_head *i;
 
-       __u32 n = (__u32) bucket;
+       u32 n = (u32) bucket;
 
        /* yaffs_check_obj_hash_sane();  */
 
@@ -1390,10 +1291,10 @@ static int yaffs_new_obj_id(yaffs_dev_t *dev)
                found = 1;
                n += YAFFS_NOBJECT_BUCKETS;
                if (1 || dev->obj_bucket[bucket].count > 0) {
-                       ylist_for_each(i, &dev->obj_bucket[bucket].list) {
+    &nbs