summaryrefslogtreecommitdiffstats
path: root/target/linux/generic-2.6/files-2.6.25/fs/yaffs2
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/generic-2.6/files-2.6.25/fs/yaffs2')
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Kconfig23
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Makefile5
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/devextras.h231
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/moduleconfig.h4
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_checkptrw.c6
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_ecc.c2
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_fs.c102
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_getblockinfo.h34
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.c393
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.h71
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.c14
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.h5
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1-compat.c434
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1.c18
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif2.c134
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nand.c5
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nandemul2k.h4
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.c130
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.h5
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.c9
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.h5
-rw-r--r--target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yportenv.h17
22 files changed, 989 insertions, 662 deletions
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Kconfig b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Kconfig
index de1516390..7b6f836cd 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Kconfig
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Kconfig
@@ -43,8 +43,7 @@ config YAFFS_9BYTE_TAGS
format that you need to continue to support. New data written
also uses the older-style format. Note: Use of this option
generally requires that MTD's oob layout be adjusted to use the
- older-style format. See notes on tags formats and MTD versions
- in yaffs_mtdif1.c.
+ older-style format. See notes on tags formats and MTD versions.
If unsure, say N.
@@ -110,6 +109,26 @@ config YAFFS_DISABLE_LAZY_LOAD
If unsure, say N.
+config YAFFS_CHECKPOINT_RESERVED_BLOCKS
+ int "Reserved blocks for checkpointing"
+ depends on YAFFS_YAFFS2
+ default 10
+ help
+ Give the number of Blocks to reserve for checkpointing.
+ Checkpointing saves the state at unmount so that mounting is
+ much faster as a scan of all the flash to regenerate this state
+ is not needed. These Blocks are reserved per partition, so if
+ you have very small partitions the default (10) may be a mess
+ for you. You can set this value to 0, but that does not mean
+ checkpointing is disabled at all. There only won't be any
+ specially reserved blocks for checkpointing, so if there is
+ enough free space on the filesystem, it will be used for
+ checkpointing.
+
+ If unsure, leave at default (10), but don't wonder if there are
+ always 2MB used on your large page device partition (10 x 2k
+ pagesize). When using small partitions or when being very small
+ on space, you probably want to set this to zero.
config YAFFS_DISABLE_WIDE_TNODES
bool "Turn off wide tnodes"
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Makefile b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Makefile
index 382ee6142..73f46583f 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Makefile
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/Makefile
@@ -5,6 +5,7 @@
obj-$(CONFIG_YAFFS_FS) += yaffs.o
yaffs-y := yaffs_ecc.o yaffs_fs.o yaffs_guts.o yaffs_checkptrw.o
-yaffs-y += yaffs_packedtags1.o yaffs_packedtags2.o yaffs_nand.o yaffs_qsort.o
+yaffs-y += yaffs_packedtags2.o yaffs_nand.o yaffs_qsort.o
yaffs-y += yaffs_tagscompat.o yaffs_tagsvalidity.o
-yaffs-y += yaffs_mtdif.o yaffs_mtdif1.o yaffs_mtdif2.o
+yaffs-y += yaffs_mtdif1.o yaffs_packedtags1.o
+yaffs-y += yaffs_mtdif.o yaffs_mtdif2.o
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/devextras.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/devextras.h
index 55c31219d..fcf2690a5 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/devextras.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/devextras.h
@@ -14,117 +14,194 @@
*/
/*
- * 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.
+ * This file is just holds extra declarations used during development.
+ * Most of these are from kernel includes placed here so we can use them in
+ * applications.
*
*/
#ifndef __EXTRAS_H__
#define __EXTRAS_H__
+#if defined WIN32
+#define __inline__ __inline
+#define new newHack
+#endif
+
+#if !(defined __KERNEL__) || (defined WIN32)
-#if !(defined __KERNEL__)
+/* User space defines */
-/* Definition of types */
typedef unsigned char __u8;
typedef unsigned short __u16;
typedef unsigned __u32;
-#endif
-
/*
- * This is a simple doubly linked list implementation that matches the
- * way the Linux kernel doubly linked list implementation works.
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
*/
-struct ylist_head {
- struct ylist_head *next; /* next in chain */
- struct ylist_head *prev; /* previous in chain */
+#define prefetch(x) 1
+
+struct list_head {
+ struct list_head *next, *prev;
};
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
-/* Initialise a list head to an empty list */
-#define YINIT_LIST_HEAD(p) \
-do { \
- (p)->next = (p);\
- (p)->prev = (p); \
-} while(0)
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+#define INIT_LIST_HEAD(ptr) do { \
+ (ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
-/* Add an element to a list */
-static __inline__ void ylist_add(struct ylist_head *newEntry,
- struct ylist_head *list)
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void __list_add(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next)
{
- struct ylist_head *listNext = list->next;
-
- list->next = newEntry;
- newEntry->prev = list;
- newEntry->next = listNext;
- listNext->prev = newEntry;
-
+ next->prev = new;
+ new->next = next;
+ new->prev = prev;
+ prev->next = new;
}
-
-/* Take an element out of its current list, with or without
- * reinitialising the links.of the entry*/
-static __inline__ void ylist_del(struct ylist_head *entry)
+/**
+ * list_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static __inline__ void list_add(struct list_head *new, struct list_head *head)
{
- struct ylist_head *listNext = entry->next;
- struct ylist_head *listPrev = entry->prev;
-
- listNext->prev = listPrev;
- listPrev->next = listNext;
-
+ __list_add(new, head, head->next);
}
-static __inline__ void ylist_del_init(struct ylist_head *entry)
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static __inline__ void list_add_tail(struct list_head *new,
+ struct list_head *head)
{
- ylist_del(entry);
- entry->next = entry->prev = entry;
+ __list_add(new, head->prev, head);
}
-
-/* Test if the list is empty */
-static __inline__ int ylist_empty(struct ylist_head *entry)
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __inline__ void __list_del(struct list_head *prev,
+ struct list_head *next)
{
- return (entry->next == entry);
+ next->prev = prev;
+ prev->next = next;
}
-
-/* ylist_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.
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty on entry does not return true after this, the entry is
+ * in an undefined state.
*/
-
-
-#define ylist_entry(entry, type, member) \
- ((type *)((char *)(entry)-(unsigned long)(&((type *)NULL)->member)))
-
+static __inline__ void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+}
-/* 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_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
*/
+static __inline__ void list_del_init(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ INIT_LIST_HEAD(entry);
+}
-#define ylist_for_each(itervar, list) \
- for (itervar = (list)->next; itervar != (list); itervar = itervar->next )
-
-#define ylist_for_each_safe(itervar,saveVar, list) \
- for (itervar = (list)->next, saveVar = (list)->next->next; itervar != (list); \
- itervar = saveVar, saveVar = saveVar->next)
-
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static __inline__ int list_empty(struct list_head *head)
+{
+ return head->next == head;
+}
-#if !(defined __KERNEL__)
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static __inline__ void list_splice(struct list_head *list,
+ struct list_head *head)
+{
+ struct list_head *first = list->next;
+ if (first != list) {
+ struct list_head *last = list->prev;
+ struct list_head *at = head->next;
-#ifndef WIN32
-#include <sys/stat.h>
-#endif
+ first->prev = head;
+ head->next = first;
+ last->next = at;
+ at->prev = last;
+ }
+}
-#ifdef CONFIG_YAFFS_PROVIDE_DEFS
-/* File types */
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+/**
+ * list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop counter.
+ * @head: the head for your list.
+ */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next, prefetch(pos->next); pos != (head); \
+ pos = pos->next, prefetch(pos->next))
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal
+ * of list entry
+ * @pos: the &struct list_head to use as a loop counter.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
+/*
+ * File types
+ */
#define DT_UNKNOWN 0
#define DT_FIFO 1
#define DT_CHR 2
@@ -135,13 +212,13 @@ static __inline__ int ylist_empty(struct ylist_head *entry)
#define DT_SOCK 12
#define DT_WHT 14
-
#ifndef WIN32
#include <sys/stat.h>
#endif
/*
- * Attribute flags.
+ * Attribute flags. These should be or-ed together to figure out what
+ * has been changed!
*/
#define ATTR_MODE 1
#define ATTR_UID 2
@@ -150,7 +227,10 @@ static __inline__ int ylist_empty(struct ylist_head *entry)
#define ATTR_ATIME 16
#define ATTR_MTIME 32
#define ATTR_CTIME 64
-
+#define ATTR_ATIME_SET 128
+#define ATTR_MTIME_SET 256
+#define ATTR_FORCE 512 /* Not a change, but a change it */
+#define ATTR_ATTR_FLAG 1024
struct iattr {
unsigned int ia_valid;
@@ -164,18 +244,21 @@ struct iattr {
unsigned int ia_attr_flags;
};
-#endif
-
-
#define KERN_DEBUG
#else
+#ifndef WIN32
#include <linux/types.h>
+#include <linux/list.h>
#include <linux/fs.h>
#include <linux/stat.h>
+#endif
#endif
+#if defined WIN32
+#undef new
+#endif
#endif
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/moduleconfig.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/moduleconfig.h
index ac5af6f35..016391ca5 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/moduleconfig.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/moduleconfig.h
@@ -54,11 +54,11 @@ that you need to continue to support. New data written also uses the
older-style format.
Note: Use of this option generally requires that MTD's oob layout be
adjusted to use the older-style format. See notes on tags formats and
-MTD versions in yaffs_mtdif1.c.
+MTD versions.
*/
/* Default: Not selected */
/* Meaning: Use older-style on-NAND data format with pageStatus byte */
-//#define CONFIG_YAFFS_9BYTE_TAGS
+#define CONFIG_YAFFS_9BYTE_TAGS
#endif /* YAFFS_OUT_OF_TREE */
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_checkptrw.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_checkptrw.c
index 68e6d0ce5..933a33fb8 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_checkptrw.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_checkptrw.c
@@ -12,11 +12,11 @@
*/
const char *yaffs_checkptrw_c_version =
- "$Id: yaffs_checkptrw.c,v 1.16 2008-05-05 07:58:58 charles Exp $";
+ "$Id: yaffs_checkptrw.c,v 1.14 2007-05-15 20:07:40 charles Exp $";
#include "yaffs_checkptrw.h"
-#include "yaffs_getblockinfo.h"
+
static int yaffs_CheckpointSpaceOk(yaffs_Device *dev)
{
@@ -142,7 +142,7 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
return 0;
if(!dev->checkpointBuffer)
- dev->checkpointBuffer = YMALLOC_DMA(dev->totalBytesPerChunk);
+ dev->checkpointBuffer = YMALLOC_DMA(dev->nDataBytesPerChunk);
if(!dev->checkpointBuffer)
return 0;
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_ecc.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_ecc.c
index 9f5973a5b..e2860393d 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_ecc.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_ecc.c
@@ -29,7 +29,7 @@
*/
const char *yaffs_ecc_c_version =
- "$Id: yaffs_ecc.c,v 1.10 2007-12-13 15:35:17 wookey Exp $";
+ "$Id: yaffs_ecc.c,v 1.9 2007-02-14 01:09:06 wookey Exp $";
#include "yportenv.h"
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_fs.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_fs.c
index ab6a3a7e0..67001b10e 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_fs.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_fs.c
@@ -32,7 +32,7 @@
*/
const char *yaffs_fs_c_version =
- "$Id: yaffs_fs.c,v 1.66 2008-05-05 07:58:58 charles Exp $";
+ "$Id: yaffs_fs.c,v 1.63 2007-09-19 20:35:40 imcd Exp $";
extern const char *yaffs_guts_c_version;
#include <linux/version.h>
@@ -53,8 +53,6 @@ extern const char *yaffs_guts_c_version;
#include <linux/string.h>
#include <linux/ctype.h>
-#include "asm/div64.h"
-
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
#include <linux/statfs.h> /* Added NCB 15-8-2003 */
@@ -755,8 +753,6 @@ static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
break;
}
- inode->i_flags |= S_NOATIME;
-
inode->i_ino = obj->objectId;
inode->i_mode = obj->yst_mode;
inode->i_uid = obj->yst_uid;
@@ -1354,47 +1350,25 @@ static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
buf->f_type = YAFFS_MAGIC;
buf->f_bsize = sb->s_blocksize;
buf->f_namelen = 255;
-
- if(dev->nDataBytesPerChunk & (dev->nDataBytesPerChunk - 1)){
- /* Do this if chunk size is not a power of 2 */
-
- uint64_t bytesInDev;
- uint64_t bytesFree;
-
- bytesInDev = ((uint64_t)((dev->endBlock - dev->startBlock +1))) *
- ((uint64_t)(dev->nChunksPerBlock * dev->nDataBytesPerChunk));
-
- do_div(bytesInDev,sb->s_blocksize); /* bytesInDev becomes the number of blocks */
- buf->f_blocks = bytesInDev;
-
- bytesFree = ((uint64_t)(yaffs_GetNumberOfFreeChunks(dev))) *
- ((uint64_t)(dev->nDataBytesPerChunk));
-
- do_div(bytesFree,sb->s_blocksize);
-
- buf->f_bfree = bytesFree;
-
- } else if (sb->s_blocksize > dev->nDataBytesPerChunk) {
-
+ if (sb->s_blocksize > dev->nDataBytesPerChunk) {
+
buf->f_blocks =
- (dev->endBlock - dev->startBlock + 1) *
- dev->nChunksPerBlock /
- (sb->s_blocksize / dev->nDataBytesPerChunk);
- buf->f_bfree =
- yaffs_GetNumberOfFreeChunks(dev) /
- (sb->s_blocksize / dev->nDataBytesPerChunk);
+ (dev->endBlock - dev->startBlock +
+ 1) * dev->nChunksPerBlock / (sb->s_blocksize /
+ dev->nDataBytesPerChunk);
+ buf->f_bfree =
+ yaffs_GetNumberOfFreeChunks(dev) / (sb->s_blocksize /
+ dev->nDataBytesPerChunk);
} else {
- buf->f_blocks =
- (dev->endBlock - dev->startBlock + 1) *
- dev->nChunksPerBlock *
- (dev->nDataBytesPerChunk / sb->s_blocksize);
-
- buf->f_bfree =
- yaffs_GetNumberOfFreeChunks(dev) *
- (dev->nDataBytesPerChunk / sb->s_blocksize);
+
+ buf->f_blocks =
+ (dev->endBlock - dev->startBlock +
+ 1) * dev->nChunksPerBlock * (dev->nDataBytesPerChunk /
+ sb->s_blocksize);
+ buf->f_bfree =
+ yaffs_GetNumberOfFreeChunks(dev) * (dev->nDataBytesPerChunk /
+ sb->s_blocksize);
}
-
-
buf->f_files = 0;
buf->f_ffree = 0;
buf->f_bavail = buf->f_bfree;
@@ -1628,7 +1602,6 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
sb->s_magic = YAFFS_MAGIC;
sb->s_op = &yaffs_super_ops;
- sb->s_flags |= MS_NOATIME;
if (!sb)
printk(KERN_INFO "yaffs: sb is NULL\n");
@@ -1705,15 +1678,22 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
#ifdef CONFIG_YAFFS_AUTO_YAFFS2
if (yaffsVersion == 1 &&
- WRITE_SIZE(mtd) >= 2048) {
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+ mtd->writesize >= 2048) {
+#else
+ mtd->oobblock >= 2048) {
+#endif
T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n"));
yaffsVersion = 2;
}
/* Added NCB 26/5/2006 for completeness */
- if (yaffsVersion == 2 &&
- !options.inband_tags &&
- WRITE_SIZE(mtd) == 512){
+ if (yaffsVersion == 2 &&
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+ mtd->writesize == 512) {
+#else
+ mtd->oobblock == 512) {
+#endif
T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs1\n"));
yaffsVersion = 1;
}
@@ -1739,9 +1719,12 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
return NULL;
}
- if ((WRITE_SIZE(mtd) < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
- mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE) &&
- !options.inband_tags) {
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+ if (mtd->writesize < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
+#else
+ if (mtd->oobblock < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
+#endif
+ mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE) {
T(YAFFS_TRACE_ALWAYS,
("yaffs: MTD device does not have the "
"right page sizes\n"));
@@ -1801,10 +1784,9 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
dev->startBlock = 0;
dev->endBlock = nBlocks - 1;
dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
- dev->totalBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
+ dev->nDataBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
dev->nReservedBlocks = 5;
dev->nShortOpCaches = (options.no_cache) ? 0 : 10;
- dev->inbandTags = options.inband_tags;
/* ... and the functions. */
if (yaffsVersion == 2) {
@@ -1817,14 +1799,15 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
dev->spareBuffer = YMALLOC(mtd->oobsize);
dev->isYaffs2 = 1;
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
- dev->totalBytesPerChunk = mtd->writesize;
+ dev->nDataBytesPerChunk = mtd->writesize;
dev->nChunksPerBlock = mtd->erasesize / mtd->writesize;
#else
- dev->totalBytesPerChunk = mtd->oobblock;
+ dev->nDataBytesPerChunk = mtd->oobblock;
dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
#endif
nBlocks = mtd->size / mtd->erasesize;
+ dev->nCheckpointReservedBlocks = CONFIG_YAFFS_CHECKPOINT_RESERVED_BLOCKS;
dev->startBlock = 0;
dev->endBlock = nBlocks - 1;
} else {
@@ -2007,12 +1990,12 @@ static char *yaffs_dump_dev(char *buf, yaffs_Device * dev)
{
buf += sprintf(buf, "startBlock......... %d\n", dev->startBlock);
buf += sprintf(buf, "endBlock........... %d\n", dev->endBlock);
- buf += sprintf(buf, "totalBytesPerChunk. %d\n", dev->totalBytesPerChunk);
buf += sprintf(buf, "nDataBytesPerChunk. %d\n", dev->nDataBytesPerChunk);
buf += sprintf(buf, "chunkGroupBits..... %d\n", dev->chunkGroupBits);
buf += sprintf(buf, "chunkGroupSize..... %d\n", dev->chunkGroupSize);
buf += sprintf(buf, "nErasedBlocks...... %d\n", dev->nErasedBlocks);
buf += sprintf(buf, "nReservedBlocks.... %d\n", dev->nReservedBlocks);
+ buf += sprintf(buf, "nCheckptResBlocks.. %d\n", dev->nCheckpointReservedBlocks);
buf += sprintf(buf, "blocksInCheckpoint. %d\n", dev->blocksInCheckpoint);
buf += sprintf(buf, "nTnodesCreated..... %d\n", dev->nTnodesCreated);
buf += sprintf(buf, "nFreeTnodes........ %d\n", dev->nFreeTnodes);
@@ -2023,8 +2006,10 @@ static char *yaffs_dump_dev(char *buf, yaffs_Device * dev)
buf += sprintf(buf, "nPageReads......... %d\n", dev->nPageReads);
buf += sprintf(buf, "nBlockErasures..... %d\n", dev->nBlockErasures);
buf += sprintf(buf, "nGCCopies.......... %d\n", dev->nGCCopies);
- buf += sprintf(buf, "garbageCollections. %d\n", dev->garbageCollections);
- buf += sprintf(buf, "passiveGCs......... %d\n",
+ buf +=
+ sprintf(buf, "garbageCollections. %d\n", dev->garbageCollections);
+ buf +=
+ sprintf(buf, "passiveGCs......... %d\n",
dev->passiveGarbageCollections);
buf += sprintf(buf, "nRetriedWrites..... %d\n", dev->nRetriedWrites);
buf += sprintf(buf, "nShortOpCaches..... %d\n", dev->nShortOpCaches);
@@ -2040,7 +2025,6 @@ static char *yaffs_dump_dev(char *buf, yaffs_Device * dev)
sprintf(buf, "nBackgroudDeletions %d\n", dev->nBackgroundDeletions);
buf += sprintf(buf, "useNANDECC......... %d\n", dev->useNANDECC);
buf += sprintf(buf, "isYaffs2........... %d\n", dev->isYaffs2);
- buf += sprintf(buf, "inbandTags......... %d\n", dev->inbandTags);
return buf;
}
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_getblockinfo.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_getblockinfo.h
deleted file mode 100644
index b9742ac0a..000000000
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_getblockinfo.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
- *
- * Copyright (C) 2002-2007 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 __YAFFS_GETBLOCKINFO_H__
-#define __YAFFS_GETBLOCKINFO_H__
-
-#include "yaffs_guts.h"
-
-/* Function to manipulate block info */
-static Y_INLINE yaffs_BlockInfo *yaffs_GetBlockInfo(yaffs_Device * dev, int blk)
-{
- if (blk < dev->internalStartBlock || blk > dev->internalEndBlock) {
- T(YAFFS_TRACE_ERROR,
- (TSTR
- ("**>> yaffs: getBlockInfo block %d is not valid" TENDSTR),
- blk));
- YBUG();
- }
- return &dev->blockInfo[blk - dev->internalStartBlock];
-}
-
-#endif
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.c
index 223f2c130..2ab814691 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.c
@@ -12,14 +12,13 @@
*/
const char *yaffs_guts_c_version =
- "$Id: yaffs_guts.c,v 1.56 2008-05-08 23:23:26 charles Exp $";
+ "$Id: yaffs_guts.c,v 1.49 2007-05-15 20:07:40 charles Exp $";
#include "yportenv.h"
#include "yaffsinterface.h"
#include "yaffs_guts.h"
#include "yaffs_tagsvalidity.h"
-#include "yaffs_getblockinfo.h"
#include "yaffs_tagscompat.h"
#ifndef CONFIG_YAFFS_USE_OWN_SORT
@@ -79,6 +78,9 @@ static int yaffs_DoGenericObjectDeletion(yaffs_Object * in);
static yaffs_BlockInfo *yaffs_GetBlockInfo(yaffs_Device * dev, int blockNo);
+static __u8 *yaffs_GetTempBuffer(yaffs_Device * dev, int lineNo);
+static void yaffs_ReleaseTempBuffer(yaffs_Device * dev, __u8 * buffer,
+ int lineNo);
static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,
int chunkInNAND);
@@ -119,32 +121,23 @@ static yaffs_Tnode *yaffs_FindLevel0Tnode(yaffs_Device * dev,
/* Function to calculate chunk and offset */
-static void yaffs_AddrToChunk(yaffs_Device *dev, loff_t addr, int *chunkOut, __u32 *offsetOut)
+static void yaffs_AddrToChunk(yaffs_Device *dev, loff_t addr, __u32 *chunk, __u32 *offset)
{
- int chunk;
- __u32 offset;
-
- chunk = (__u32)(addr >> dev->chunkShift);
-
- if(dev->chunkDiv == 1)
- {
- /* easy power of 2 case */
- offset = (__u32)(addr & dev->chunkMask);
+ if(dev->chunkShift){
+ /* Easy-peasy power of 2 case */
+ *chunk = (__u32)(addr >> dev->chunkShift);
+ *offset = (__u32)(addr & dev->chunkMask);
}
- else
+ else if(dev->crumbsPerChunk)
{
- /* Non power-of-2 case */
-
- loff_t chunkBase;
-
- chunk /= dev->chunkDiv;
-
- chunkBase = ((loff_t)chunk) * dev->nDataBytesPerChunk;
- offset = (__u32)(addr - chunkBase);
+ /* Case where we're using "crumbs" */
+ *offset = (__u32)(addr & dev->crumbMask);
+ addr >>= dev->crumbShift;
+ *chunk = ((__u32)addr)/dev->crumbsPerChunk;
+ *offset += ((addr - (*chunk * dev->crumbsPerChunk)) << dev->crumbShift);
}
-
- *chunkOut = chunk;
- *offsetOut = offset;
+ else
+ YBUG();
}
/* Function to return the number of shifts for a power of 2 greater than or equal
@@ -175,7 +168,7 @@ static __u32 ShiftsGE(__u32 x)
/* Function to return the number of shifts to get a 1 in bit 0
*/
-static __u32 Shifts(__u32 x)
+static __u32 ShiftDiv(__u32 x)
{
int nShifts;
@@ -207,21 +200,16 @@ static int yaffs_InitialiseTempBuffers(yaffs_Device *dev)
for (i = 0; buf && i < YAFFS_N_TEMP_BUFFERS; i++) {
dev->tempBuffer[i].line = 0; /* not in use */
dev->tempBuffer[i].buffer = buf =
- YMALLOC_DMA(dev->totalBytesPerChunk);
+ YMALLOC_DMA(dev->nDataBytesPerChunk);
}
return buf ? YAFFS_OK : YAFFS_FAIL;
}
-__u8 *yaffs_GetTempBuffer(yaffs_Device * dev, int lineNo)
+static __u8 *yaffs_GetTempBuffer(yaffs_Device * dev, int lineNo)
{
int i, j;
-
- dev->tempInUse++;
- if(dev->tempInUse > dev->maxTemp)
- dev->maxTemp = dev->tempInUse;
-
for (i = 0; i < YAFFS_N_TEMP_BUFFERS; i++) {
if (dev->tempBuffer[i].line == 0) {
dev->tempBuffer[i].line = lineNo;
@@ -254,13 +242,10 @@ __u8 *yaffs_GetTempBuffer(yaffs_Device * dev, int lineNo)
}
-void yaffs_ReleaseTempBuffer(yaffs_Device * dev, __u8 * buffer,
+static void yaffs_ReleaseTempBuffer(yaffs_Device * dev, __u8 * buffer,
int lineNo)
{
int i;
-
- dev->tempInUse--;
-
for (i = 0; i < YAFFS_N_TEMP_BUFFERS; i++) {
if (dev->tempBuffer[i].buffer == buffer) {
dev->tempBuffer[i].line = 0;
@@ -405,14 +390,11 @@ static int yaffs_SkipVerification(yaffs_Device *dev)
return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY | YAFFS_TRACE_VERIFY_FULL));
}
-#if 0
static int yaffs_SkipFullVerification(yaffs_Device *dev)
{
return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY_FULL));
}
-#endif
-
static int yaffs_SkipNANDVerification(yaffs_Device *dev)
{
return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY_NAND));
@@ -615,6 +597,7 @@ static int yaffs_VerifyTnodeWorker(yaffs_Object * obj, yaffs_Tnode * tn,
int i;
yaffs_Device *dev = obj->myDev;
int ok = 1;
+ int nTnodeBytes = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
if (tn) {
if (level > 0) {
@@ -663,6 +646,7 @@ static void yaffs_VerifyFile(yaffs_Object *obj)
__u32 lastChunk;
__u32 x;
__u32 i;
+ int ok;
yaffs_Device *dev;
yaffs_ExtendedTags tags;
yaffs_Tnode *tn;
@@ -845,7 +829,7 @@ static void yaffs_VerifyObjects(yaffs_Device *dev)
{
yaffs_Object *obj;
int i;
- struct ylist_head *lh;
+ struct list_head *lh;
if(yaffs_SkipVerification(dev))
return;
@@ -853,9 +837,9 @@ static void yaffs_VerifyObjects(yaffs_Device *dev)
/* Iterate through the objects in each hash entry */
for(i = 0; i < YAFFS_NOBJECT_BUCKETS; i++){
- ylist_for_each(lh, &dev->objectBucket[i].list) {
+ list_for_each(lh, &dev->objectBucket[i].list) {
if (lh) {
- obj = ylist_entry(lh, yaffs_Object, hashLink);
+ obj = list_entry(lh, yaffs_Object, hashLink);
yaffs_VerifyObject(obj);
}
}
@@ -931,6 +915,7 @@ static int yaffs_CheckChunkErased(struct yaffs_DeviceStruct *dev,
}
+
static int yaffs_WriteNewChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,
const __u8 * data,
yaffs_ExtendedTags * tags,
@@ -1007,11 +992,7 @@ static int yaffs_WriteNewChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,
/* Copy the data into the robustification buffer */
yaffs_HandleWriteChunkOk(dev, chunk, data, tags);
- } while (writeOk != YAFFS_OK &&
- (yaffs_wr_attempts <= 0 || attempts <= yaffs_wr_attempts));
-
- if(!writeOk)
- chunk = -1;
+ } while (writeOk != YAFFS_OK && attempts < yaffs_wr_attempts);
if (attempts > 1) {
T(YAFFS_TRACE_ERROR,
@@ -1162,10 +1143,6 @@ static int yaffs_CreateTnodes(yaffs_Device * dev, int nTnodes)
* Must be a multiple of 32-bits */
tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
- if(tnodeSize < sizeof(yaffs_Tnode))
- tnodeSize = sizeof(yaffs_Tnode);
-
-
/* make these things */
newTnodes = YMALLOC(nTnodes * tnodeSize);
@@ -1256,21 +1233,15 @@ static yaffs_Tnode *yaffs_GetTnodeRaw(yaffs_Device * dev)
dev->nFreeTnodes--;
}
- dev->nCheckpointBlocksRequired = 0; /* force recalculation*/
-
return tn;
}
static yaffs_Tnode *yaffs_GetTnode(yaffs_Device * dev)
{
yaffs_Tnode *tn = yaffs_GetTnodeRaw(dev);
- int tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
-
- if(tnodeSize < sizeof(yaffs_Tnode))
- tnodeSize = sizeof(yaffs_Tnode);
if(tn)
- memset(tn, 0, tnodeSize);
+ memset(tn, 0, (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8);
return tn;
}
@@ -1291,8 +1262,6 @@ static void yaffs_FreeTnode(yaffs_Device * dev, yaffs_Tnode * tn)
dev->freeTnodes = tn;
dev->nFreeTnodes++;
}
- dev->nCheckpointBlocksRequired = 0; /* force recalculation*/
-
}
static void yaffs_DeinitialiseTnodes(yaffs_Device * dev)
@@ -1885,7 +1854,7 @@ static int yaffs_CreateFreeObjects(yaffs_Device * dev, int nObjects)
/* Hook them into the free list */
for (i = 0; i < nObjects - 1; i++) {
newObjects[i].siblings.next =
- (struct ylist_head *)(&newObjects[i + 1]);
+ (struct list_head *)(&newObjects[i + 1]);
}
newObjects[nObjects - 1].siblings.next = (void *)dev->freeObjects;
@@ -1925,9 +1894,9 @@ static yaffs_Object *yaffs_AllocateEmptyObject(yaffs_Device * dev)
tn->myDev = dev;
tn->chunkId = -1;
tn->variantType = YAFFS_OBJECT_TYPE_UNKNOWN;
- YINIT_LIST_HEAD(&(tn->hardLinks));
- YINIT_LIST_HEAD(&(tn->hashLink));
- YINIT_LIST_HEAD(&tn->siblings);
+ INIT_LIST_HEAD(&(tn->hardLinks));
+ INIT_LIST_HEAD(&(tn->hashLink));
+ INIT_LIST_HEAD(&tn->siblings);
/* Add it to the lost and found directory.
* NB Can't put root or lostNFound in lostNFound so
@@ -1938,8 +1907,6 @@ static yaffs_Object *yaffs_AllocateEmptyObject(yaffs_Device * dev)
}
}
- dev->nCheckpointBlocksRequired = 0; /* force recalculation*/
-
return tn;
}
@@ -1970,8 +1937,8 @@ static void yaffs_UnhashObject(yaffs_Object * tn)
yaffs_Device *dev = tn->myDev;
/* If it is still linked into the bucket list, free from the list */
- if (!ylist_empty(&tn->hashLink)) {
- ylist_del_init(&tn->hashLink);
+ if (!list_empty(&tn->hashLink)) {
+ list_del_init(&tn->hashLink);
bucket = yaffs_HashFunction(tn->objectId);
dev->objectBucket[bucket].count--;
}
@@ -1997,12 +1964,9 @@ static void yaffs_FreeObject(yaffs_Object * tn)
yaffs_UnhashObject(tn);
/* Link into the free list. */
- tn->siblings.next = (struct ylist_head *)(dev->freeObjects);
+ tn->siblings.next = (struct list_head *)(dev->freeObjects);
dev->freeObjects = tn;
dev->nFreeObjects++;
-
- dev->nCheckpointBlocksRequired = 0; /* force recalculation*/
-
}
#ifdef __KERNEL__
@@ -2043,7 +2007,7 @@ static void yaffs_InitialiseObjects(yaffs_Device * dev)
dev->nFreeObjects = 0;
for (i = 0; i < YAFFS_NOBJECT_BUCKETS; i++) {
- YINIT_LIST_HEAD(&dev->objectBucket[i].list);
+ INIT_LIST_HEAD(&dev->objectBucket[i].list);
dev->objectBucket[i].count = 0;
}
@@ -2094,7 +2058,7 @@ static int yaffs_CreateNewObjectNumber(yaffs_Device * dev)
*/
int found = 0;
- struct ylist_head *i;
+ struct list_head *i;
__u32 n = (__u32) bucket;
@@ -2104,10 +2068,10 @@ static int yaffs_CreateNewObjectNumber(yaffs_Device * dev)
found = 1;
n += YAFFS_NOBJECT_BUCKETS;
if (1 || dev->objectBucket[bucket].count > 0) {
- ylist_for_each(i, &dev->objectBucket[bucket].list) {
+ list_for_each(i, &dev->objectBucket[bucket].list) {
/* If there is already one in the list */
if (i
- && ylist_entry(i, yaffs_Object,
+ && list_entry(i, yaffs_Object,
hashLink)->objectId == n) {
found = 0;
}
@@ -2124,7 +2088,7 @@ static void yaffs_HashObject(yaffs_Object * in)
int bucket = yaffs_HashFunction(in->objectId);
yaffs_Device *dev = in->myDev;
- ylist_add(&in->hashLink, &dev->objectBucket[bucket].list);
+ list_add(&in->hashLink, &dev->objectBucket[bucket].list);
dev->objectBucket[bucket].count++;
}
@@ -2132,13 +2096,13 @@ static void yaffs_HashObject(yaffs_Object * in)
yaffs_Object *yaffs_FindObjectByNumber(yaffs_Device * dev, __u32 number)
{
int bucket = yaffs_HashFunction(number);
- struct ylist_head *i;
+ struct list_head *i;
yaffs_Object *in;
- ylist_for_each(i, &dev->objectBucket[bucket].list) {
+ list_for_each(i, &dev->objectBucket[bucket].list) {
/* Look if it is in the list */
if (i) {
- in = ylist_entry(i, yaffs_Object, hashLink);
+ in = list_entry(i, yaffs_Object, hashLink);
if (in->objectId == number) {
#ifdef __KERNEL__
/* Don't tell the VFS about this one if it is defered free */
@@ -2159,7 +2123,7 @@ yaffs_Object *yaffs_CreateNewObject(yaffs_Device * dev, int number,
{
yaffs_Object *theObject;
- yaffs_Tnode *tn = NULL;
+ yaffs_Tnode *tn;
if (number < 0) {
number = yaffs_CreateNewObjectNumber(dev);
@@ -2207,7 +2171,7 @@ yaffs_Object *yaffs_CreateNewObject(yaffs_Device * dev, int number,
theObject->variant.fileVariant.top = tn;
break;
case YAFFS_OBJECT_TYPE_DIRECTORY:
- YINIT_LIST_HEAD(&theObject->variant.directoryVariant.
+ INIT_LIST_HEAD(&theObject->variant.directoryVariant.
children);
break;
case YAFFS_OBJECT_TYPE_SYMLINK:
@@ -2274,7 +2238,7 @@ static yaffs_Object *yaffs_MknodObject(yaffs_ObjectType type,
const YCHAR * aliasString, __u32 rdev)
{
yaffs_Object *in;
- YCHAR *str = NULL;
+ YCHAR *str;
yaffs_Device *dev = parent->myDev;
@@ -2332,7 +2296,7 @@ static yaffs_Object *yaffs_MknodObject(yaffs_ObjectType type,
equivalentObject;
in->variant.hardLinkVariant.equivalentObjectId =
equivalentObject->objectId;
- ylist_add(&in->hardLinks, &equivalentObject->hardLinks);
+ list_add(&in->hardLinks, &equivalentObject->hardLinks);
break;
case YAFFS_OBJECT_TYPE_FILE:
case YAFFS_OBJECT_TYPE_DIRECTORY:
@@ -2493,7 +2457,7 @@ int yaffs_RenameObject(yaffs_Object * oldDir, const YCHAR * oldName,
existingTarget = yaffs_FindObjectByName(newDir, newName);
if (existingTarget &&
existingTarget->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
- !ylist_empty(&existingTarget->variant.directoryVariant.children)) {
+ !list_empty(&existingTarget->variant.directoryVariant.children)) {
/* There is a target that is a non-empty directory, so we fail */
return YAFFS_FAIL; /* EEXIST or ENOTEMPTY */
} else if (existingTarget && existingTarget != obj) {
@@ -2837,40 +2801,6 @@ static int yaffs_FindBlockForAllocation(yaffs_Device * dev)
}
-
-static int yaffs_CalcCheckpointBlocksRequired(yaffs_Device *dev)
-{
- if(!dev->nCheckpointBlocksRequired){
- /* Not a valid value so recalculate */
- int nBytes = 0;
- int nBlocks;
- int devBlocks = (dev->endBlock - dev->startBlock + 1);
- int tnodeSize;
-
- tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
-
- if(tnodeSize < sizeof(yaffs_Tnode))
- tnodeSize = sizeof(yaffs_Tnode);
-
- nBytes += sizeof(yaffs_CheckpointValidity);
- nBytes += sizeof(yaffs_CheckpointDevice);
- nBytes += devBlocks * sizeof(yaffs_BlockInfo);
- nBytes += devBlocks * dev->chunkBitmapStride;
- nBytes += (sizeof(yaffs_CheckpointObject) + sizeof(__u32)) * (dev->nObjectsCreated - dev->nFreeObjects);
- nBytes += (tnodeSize + sizeof(__u32)) * (dev->nTnodesCreated - dev->nFreeTnodes);
- nBytes += sizeof(yaffs_CheckpointValidity);
- nBytes += sizeof(__u32); /* checksum*/
-
- /* Round up and add 2 blocks to allow for some bad blocks, so add 3 */
-
- nBlocks = (nBytes/(dev->nDataBytesPerChunk * dev->nChunksPerBlock)) + 3;
-
- dev->nCheckpointBlocksRequired = nBlocks;
- }
-
- return dev->nCheckpointBlocksRequired;
-}
-
// Check if there's space to allocate...
// Thinks.... do we need top make this ths same as yaffs_GetFreeChunks()?
static int yaffs_CheckSpaceForAllocation(yaffs_Device * dev)
@@ -2879,7 +2809,7 @@ static int yaffs_CheckSpaceForAllocation(yaffs_Device * dev)
int reservedBlocks = dev->nReservedBlocks;
int checkpointBlocks;
- checkpointBlocks = yaffs_CalcCheckpointBlocksRequired(dev) - dev->blocksInCheckpoint;
+ checkpointBlocks = dev->nCheckpointReservedBlocks - dev->blocksInCheckpoint;
if(checkpointBlocks < 0)
checkpointBlocks = 0;
@@ -3107,7 +3037,7 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block)
yaffs_ObjectHeader *oh;
oh = (yaffs_ObjectHeader *)buffer;
oh->isShrink = 0;
- oh->shadowsObject = oh->inbandShadowsObject = -1;
+ oh->shadowsObject = -1;
tags.extraShadows = 0;
tags.extraIsShrinkHeader = 0;
@@ -3212,7 +3142,7 @@ static int yaffs_CheckGarbageCollection(yaffs_Device * dev)
do {
maxTries++;
- checkpointBlockAdjust = yaffs_CalcCheckpointBlocksRequired(dev) - dev->blocksInCheckpoint;
+ checkpointBlockAdjust = (dev->nCheckpointReservedBlocks - dev->blocksInCheckpoint);
if(checkpointBlockAdjust < 0)
checkpointBlockAdjust = 0;
@@ -3698,7 +3628,7 @@ int yaffs_UpdateObjectHeader(yaffs_Object * in, const YCHAR * name, int force,
oh->type = in->variantType;
oh->yst_mode = in->yst_mode;
- oh->shadowsObject = oh->inbandShadowsObject = shadows;
+ oh->shadowsObject = shadows;
#ifdef CONFIG_YAFFS_WINCE
oh->win_atime[0] = in->win_atime[0];
@@ -4290,11 +4220,7 @@ static int yaffs_CheckpointTnodeWorker(yaffs_Object * in, yaffs_Tnode * tn,
int i;
yaffs_Device *dev = in->myDev;
int ok = 1;
- int tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
-
- if(tnodeSize < sizeof(yaffs_Tnode))
- tnodeSize = sizeof(yaffs_Tnode);
-
+ int nTnodeBytes = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
if (tn) {
if (level > 0) {
@@ -4312,7 +4238,7 @@ static int yaffs_CheckpointTnodeWorker(yaffs_Object * in, yaffs_Tnode * tn,
/* printf("write tnode at %d\n",baseOffset); */
ok = (yaffs_CheckpointWrite(dev,&baseOffset,sizeof(baseOffset)) == sizeof(baseOffset));
if(ok)
- ok = (yaffs_CheckpointWrite(dev,tn,tnodeSize) == tnodeSize);
+ ok = (yaffs_CheckpointWrite(dev,tn,nTnodeBytes) == nTnodeBytes);
}
}
@@ -4346,10 +4272,6 @@ static int yaffs_ReadCheckpointTnodes(yaffs_Object *obj)
yaffs_FileStructure *fileStructPtr = &obj->variant.fileVariant;
yaffs_Tnode *tn;
int nread = 0;
- int tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
-
- if(tnodeSize < sizeof(yaffs_Tnode))
- tnodeSize = sizeof(yaffs_Tnode);
ok = (yaffs_CheckpointRead(dev,&baseChunk,sizeof(baseChunk)) == sizeof(baseChunk));
@@ -4361,7 +4283,8 @@ static int yaffs_ReadCheckpointTnodes(yaffs_Object *obj)
/* printf("read tnode at %d\n",baseChunk); */
tn = yaffs_GetTnodeRaw(dev);
if(tn)
- ok = (yaffs_CheckpointRead(dev,tn,tnodeSize) == tnodeSize);
+ ok = (yaffs_CheckpointRead(dev,tn,(dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8) ==
+ (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8);
else
ok = 0;
@@ -4392,7 +4315,7 @@ static int yaffs_WriteCheckpointObjects(yaffs_Device *dev)
yaffs_CheckpointObject cp;
int i;
int ok = 1;
- struct ylist_head *lh;
+ struct list_head *lh;
/* Iterate through the objects in each hash entry,
@@ -4400,9 +4323,9 @@ static int yaffs_WriteCheckpointObjects(yaffs_Device *dev)
*/
for(i = 0; ok && i < YAFFS_NOBJECT_BUCKETS; i++){
- ylist_for_each(lh, &dev->objectBucket[i].list) {
+ list_for_each(lh, &dev->objectBucket[i].list) {
if (lh) {
- obj = ylist_entry(lh, yaffs_Object, hashLink);
+ obj = list_entry(lh, yaffs_Object, hashLink);
if (!obj->deferedFree) {
yaffs_ObjectToCheckpointObject(&cp,obj);
cp.structType = sizeof(cp);
@@ -4460,7 +4383,7 @@ static int yaffs_ReadCheckpointObjects(yaffs_Device *dev)
ok = yaffs_ReadCheckpointTnodes(obj);
} else if(obj->variantType == YAFFS_OBJECT_TYPE_HARDLINK) {
obj->hardLinks.next =
- (struct ylist_head *)
+ (struct list_head *)
hardList;
hardList = obj;
}
@@ -4666,7 +4589,7 @@ int yaffs_ReadDataFromFile(yaffs_Object * in, __u8 * buffer, loff_t offset,
{
int chunk;
- __u32 start;
+ int start;
int nToCopy;
int n = nBytes;
int nDone = 0;
@@ -4694,10 +4617,10 @@ int yaffs_ReadDataFromFile(yaffs_Object * in, __u8 * buffer, loff_t offset,
cache = yaffs_FindChunkCache(in, chunk);
/* If the chunk is already in the cache or it is less than a whole chunk
- * or we're using inband tags then use the cache (if there is caching)
+ * then use the cache (if there is caching)
* else bypass the cache.
*/
- if (cache || nToCopy != dev->nDataBytesPerChunk || dev->inbandTags) {
+ if (cache || nToCopy != dev->nDataBytesPerChunk) {
if (dev->nShortOpCaches > 0) {
/* If we can't find the data in the cache, then load it up. */
@@ -4786,7 +4709,7 @@ int yaffs_WriteDataToFile(yaffs_Object * in, const __u8 * buffer, loff_t offset,
{
int chunk;
- __u32 start;
+ int start;
int nToCopy;
int n = nBytes;
int nDone = 0;
@@ -4834,10 +4757,8 @@ int yaffs_WriteDataToFile(yaffs_Object * in, const __u8 * buffer, loff_t offset,
nToWriteBack = dev->nDataBytesPerChunk;
}
- if (nToCopy != dev->nDataBytesPerChunk || dev->inbandTags) {
- /* An incomplete start or end chunk (or maybe both start and end chunk),
- * or we're using inband tags, so we want to use the cache buffers.
- */
+ if (nToCopy != dev->nDataBytesPerChunk) {
+ /* An incomplete start or end chunk (or maybe both start and end chunk) */
if (dev->nShortOpCaches > 0) {
yaffs_ChunkCache *cache;
/* If we can't find the data in the cache, then load the cache */
@@ -4925,8 +4846,7 @@ int yaffs_WriteDataToFile(yaffs_Object * in, const __u8 * buffer, loff_t offset,
}
} else {
- /* A full chunk. Write directly from the supplied buffer. */
-
+
#ifdef CONFIG_YAFFS_WINCE
/* Under WinCE can't do direct transfer. Need to use a local buffer.
* This is because we otherwise screw up WinCE's memory mapper
@@ -4945,7 +4865,7 @@ int yaffs_WriteDataToFile(yaffs_Object * in, const __u8 * buffer, loff_t offset,
0);
yaffs_ReleaseTempBuffer(dev, localBuffer, __LINE__);
#else
-
+ /* A full chunk. Write directly from the supplied buffer. */
chunkWritten =
yaffs_WriteChunkDataToObject(in, chunk, buffer,
dev->nDataBytesPerChunk,
@@ -5023,7 +4943,7 @@ int yaffs_ResizeFile(yaffs_Object * in, loff_t newSize)
{
int oldFileSize = in->variant.fileVariant.fileSize;
- __u32 newSizeOfPartialChunk;
+ int newSizeOfPartialChunk;
int newFullChunks;
yaffs_Device *dev = in->myDev;
@@ -5036,11 +4956,11 @@ int yaffs_ResizeFile(yaffs_Object * in, loff_t newSize)
yaffs_CheckGarbageCollection(dev);
if (in->variantType != YAFFS_OBJECT_TYPE_FILE) {
- return YAFFS_FAIL;
+ return yaffs_GetFileSize(in);
}
if (newSize == oldFileSize) {
- return YAFFS_OK;
+ return oldFileSize;
}
if (newSize < oldFileSize) {
@@ -5085,7 +5005,7 @@ int yaffs_ResizeFile(yaffs_Object * in, loff_t newSize)
(newSize < oldFileSize) ? 1 : 0, 0);
}
- return YAFFS_OK;
+ return newSize;
}
loff_t yaffs_GetFileSize(yaffs_Object * obj)
@@ -5138,7 +5058,7 @@ static int yaffs_DoGenericObjectDeletion(yaffs_Object * in)
if (in->myDev->isYaffs2 && (in->parent != in->myDev->deletedDir)) {
/* Move to the unlinked directory so we have a record that it was deleted. */
- yaffs_ChangeObjectName(in, in->myDev->deletedDir,_Y("deleted"), 0, 0);
+ yaffs_ChangeObjectName(in, in->myDev->deletedDir,"deleted", 0, 0);
}
@@ -5176,7 +5096,7 @@ static int yaffs_UnlinkFile(yaffs_Object * in)
if (immediateDeletion) {
retVal =
yaffs_ChangeObjectName(in, in->myDev->deletedDir,
- _Y("deleted"), 0, 0);
+ "deleted", 0, 0);
T(YAFFS_TRACE_TRACING,
(TSTR("yaffs: immediate deletion of file %d" TENDSTR),
in->objectId));
@@ -5189,7 +5109,7 @@ static int yaffs_UnlinkFile(yaffs_Object * in)
} else {
retVal =
yaffs_ChangeObjectName(in, in->myDev->unlinkedDir,
- _Y("unlinked"), 0, 0);
+ "unlinked", 0, 0);
}
}
@@ -5224,7 +5144,7 @@ int yaffs_DeleteFile(yaffs_Object * in)
static int yaffs_DeleteDirectory(yaffs_Object * in)
{
/* First check that the directory is empty. */
- if (ylist_empty(&in->variant.directoryVariant.children)) {
+ if (list_empty(&in->variant.directoryVariant.children)) {
return yaffs_DoGenericObjectDeletion(in);
}
@@ -5244,7 +5164,7 @@ static int yaffs_DeleteHardLink(yaffs_Object * in)
/* remove this hardlink from the list assocaited with the equivalent
* object
*/
- ylist_del(&in->hardLinks);
+ list_del(&in->hardLinks);
return yaffs_DoGenericObjectDeletion(in);
}
@@ -5276,7 +5196,7 @@ static int yaffs_UnlinkWorker(yaffs_Object * obj)
if (obj->variantType == YAFFS_OBJECT_TYPE_HARDLINK) {
return yaffs_DeleteHardLink(obj);
- } else if (!ylist_empty(&obj->hardLinks)) {
+ } else if (!list_empty(&obj->hardLinks)) {
/* Curve ball: We're unlinking an object that has a hardlink.
*
* This problem arises because we are not strictly following
@@ -5295,10 +5215,10 @@ static int yaffs_UnlinkWorker(yaffs_Object * obj)
int retVal;
YCHAR name[YAFFS_MAX_NAME_LENGTH + 1];
- hl = ylist_entry(obj->hardLinks.next, yaffs_Object, hardLinks);
+ hl = list_entry(obj->hardLinks.next, yaffs_Object, hardLinks);
- ylist_del_init(&hl->hardLinks);
- ylist_del_init(&hl->siblings);
+ list_del_init(&hl->hardLinks);
+ list_del_init(&hl->siblings);
yaffs_GetObjectName(hl, name, YAFFS_MAX_NAME_LENGTH + 1);
@@ -5405,13 +5325,13 @@ static void yaffs_HardlinkFixup(yaffs_Device *dev, yaffs_Object *hardList)
if (in) {
/* Add the hardlink pointers */
hl->variant.hardLinkVariant.equivalentObject = in;
- ylist_add(&hl->hardLinks, &in->hardLinks);
+ list_add(&hl->hardLinks, &in->hardLinks);
} else {
/* Todo Need to report/handle this better.
* Got a problem... hardlink to a non-existant object
*/
hl->variant.hardLinkVariant.equivalentObject = NULL;
- YINIT_LIST_HEAD(&hl->hardLinks);
+ INIT_LIST_HEAD(&hl->hardLinks);
}
@@ -5451,7 +5371,7 @@ static int yaffs_Scan(yaffs_Device * dev)
yaffs_BlockState state;
yaffs_Object *hardList = NULL;
yaffs_BlockInfo *bi;
- __u32 sequenceNumber;
+ int sequenceNumber;
yaffs_ObjectHeader *oh;
yaffs_Object *in;
yaffs_Object *parent;
@@ -5568,8 +5488,6 @@ static int yaffs_Scan(yaffs_Device * dev)
for (blockIterator = startIterator; !alloc_failed && blockIterator <= endIterator;
blockIterator++) {
- YYIELD();
-
if (dev->isYaffs2) {
/* get the block to scan in the correct order */
blk = blockIndex[blockIterator].block;
@@ -5630,7 +5548,8 @@ static int yaffs_Scan(yaffs_Device * dev)
bi->sequenceNumber)) {
T(YAFFS_TRACE_ALWAYS,
(TSTR
- ("yaffs: Allocation block %d was not highest sequence id: block seq = %d, dev seq = %d"
+ ("yaffs: Allocation block %d was not highest sequence id:"
+ " block seq = %d, dev seq = %d"
TENDSTR), blk,bi->sequenceNumber,dev->sequenceNumber));
}
}
@@ -5804,7 +5723,7 @@ static int yaffs_Scan(yaffs_Device * dev)
/* Set up as a directory */
parent->variantType =
YAFFS_OBJECT_TYPE_DIRECTORY;
- YINIT_LIST_HEAD(&parent->variant.
+ INIT_LIST_HEAD(&parent->variant.
directoryVariant.
children);
} else if (parent->variantType !=
@@ -5816,7 +5735,8 @@ static int yaffs_Scan(yaffs_Device * dev)
T(YAFFS_TRACE_ERROR,
(TSTR
- ("yaffs tragedy: attempting to use non-directory as a directory in scan. Put in lost+found."
+ ("yaffs tragedy: attempting to use non-directory as"
+ " a directory in scan. Put in lost+found."
TENDSTR)));
parent = dev->lostNFoundDir;
}
@@ -5861,7 +5781,7 @@ static int yaffs_Scan(yaffs_Device * dev)
equivalentObjectId =
oh->equivalentObjectId;
in->hardLinks.next =
- (struct ylist_head *)
+ (struct list_head *)
hardList;
hardList = in;
break;
@@ -5920,16 +5840,16 @@ static int yaffs_Scan(yaffs_Device * dev)
* just delete them.
*/
{
- struct ylist_head *i;
- struct ylist_head *n;
+ struct list_head *i;
+ struct list_head *n;
yaffs_Object *l;
/* Soft delete all the unlinked files */
- ylist_for_each_safe(i, n,
+ list_for_each_safe(i, n,
&dev->unlinkedDir->variant.directoryVariant.
children) {
if (i) {
- l = ylist_entry(i, yaffs_Object, siblings);
+ l = list_entry(i, yaffs_Object, siblings);
yaffs_DestroyObject(l);
}
}
@@ -6018,7 +5938,7 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
yaffs_BlockState state;
yaffs_Object *hardList = NULL;
yaffs_BlockInfo *bi;
- __u32 sequenceNumber;
+ int sequenceNumber;
yaffs_ObjectHeader *oh;
yaffs_Object *in;
yaffs_Object *parent;
@@ -6133,10 +6053,8 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
/* Sort the blocks */
#ifndef CONFIG_YAFFS_USE_OWN_SORT
- {
- /* Use qsort now. */
- yaffs_qsort(blockIndex, nBlocksToScan, sizeof(yaffs_BlockIndex), ybicmp);
- }
+ yaffs_qsort(blockIndex, nBlocksToScan,
+ sizeof(yaffs_BlockIndex), ybicmp);
#else
{
/* Dungy old bubble sort... */
@@ -6347,12 +6265,6 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
NULL);
oh = (yaffs_ObjectHeader *) chunkData;
-
- if(dev->inbandTags){
- /* Fix up the header if they got corrupted by inband tags */
- oh->shadowsObject = oh->inbandShadowsObject;
- oh->isShrink = oh->inbandIsShrink;
- }
if (!in)
in = yaffs_FindOrCreateObjectByNumber(dev, tags.objectId, oh->type);
@@ -6363,7 +6275,8 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
/* TODO Hoosterman we have a problem! */
T(YAFFS_TRACE_ERROR,
(TSTR
- ("yaffs tragedy: Could not make object for object %d at chunk %d during scan"
+ ("yaffs tragedy: Could not make object for object %d "
+ "at chunk %d during scan"
TENDSTR), tags.objectId, chunk));
}
@@ -6521,7 +6434,7 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
/* Set up as a directory */
parent->variantType =
YAFFS_OBJECT_TYPE_DIRECTORY;
- YINIT_LIST_HEAD(&parent->variant.
+ INIT_LIST_HEAD(&parent->variant.
directoryVariant.
children);
} else if (parent->variantType !=
@@ -6533,7 +6446,8 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
T(YAFFS_TRACE_ERROR,
(TSTR
- ("yaffs tragedy: attempting to use non-directory as a directory in scan. Put in lost+found."
+ ("yaffs tragedy: attempting to use non-directory as"
+ " a directory in scan. Put in lost+found."
TENDSTR)));
parent = dev->lostNFoundDir;
}
@@ -6584,7 +6498,7 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
in->variant.hardLinkVariant.equivalentObjectId =
equivalentObjectId;
in->hardLinks.next =
- (struct ylist_head *) hardList;
+ (struct list_head *) hardList;
hardList = in;
}
break;
@@ -6644,27 +6558,27 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
* Sort out state of unlinked and deleted objects.
*/
{
- struct ylist_head *i;
- struct ylist_head *n;
+ struct list_head *i;
+ struct list_head *n;
yaffs_Object *l;
/* Soft delete all the unlinked files */
- ylist_for_each_safe(i, n,
+ list_for_each_safe(i, n,
&dev->unlinkedDir->variant.directoryVariant.
children) {
if (i) {
- l = ylist_entry(i, yaffs_Object, siblings);
+ l = list_entry(i, yaffs_Object, siblings);
yaffs_DestroyObject(l);
}
}
/* Soft delete all the deletedDir files */
- ylist_for_each_safe(i, n,
+ list_for_each_safe(i, n,
&dev->deletedDir->variant.directoryVariant.
children) {
if (i) {
- l = ylist_entry(i, yaffs_Object, siblings);
+ l = list_entry(i, yaffs_Object, siblings);
yaffs_DestroyObject(l);
}
@@ -6691,7 +6605,7 @@ static void yaffs_RemoveObjectFromDirectory(yaffs_Object * obj)
if(dev && dev->removeObjectCallback)
dev->removeObjectCallback(obj);
- ylist_del_init(&obj->siblings);
+ list_del_init(&obj->siblings);
obj->parent = NULL;
}
@@ -6717,14 +6631,14 @@ static void yaffs_AddObjectToDirectory(yaffs_Object * directory,
if (obj->siblings.prev == NULL) {
/* Not initialised */
- YINIT_LIST_HEAD(&obj->siblings);
+ INIT_LIST_HEAD(&obj->siblings);
- } else if (!ylist_empty(&obj->siblings)) {
+ } else if (!list_empty(&obj->siblings)) {
/* If it is holed up somewhere else, un hook it */
yaffs_RemoveObjectFromDirectory(obj);
}
/* Now add it */
- ylist_add(&obj->siblings, &directory->variant.directoryVariant.children);
+ list_add(&obj->siblings, &directory->variant.directoryVariant.children);
obj->parent = directory;
if (directory == obj->myDev->unlinkedDir
@@ -6740,7 +6654,7 @@ yaffs_Object *yaffs_FindObjectByName(yaffs_Object * directory,
{
int sum;
- struct ylist_head *i;
+ struct list_head *i;
YCHAR buffer[YAFFS_MAX_NAME_LENGTH + 1];
yaffs_Object *l;
@@ -6765,9 +6679,9 @@ yaffs_Object *yaffs_FindObjectByName(yaffs_Object * directory,
sum = yaffs_CalcNameSum(name);
- ylist_for_each(i, &directory->variant.directoryVariant.children) {
+ list_for_each(i, &directory->variant.directoryVariant.children) {
if (i) {
- l = ylist_entry(i, yaffs_Object, siblings);
+ l = list_entry(i, yaffs_Object, siblings);
yaffs_CheckObjectDetailsLoaded(l);
@@ -6799,7 +6713,7 @@ yaffs_Object *yaffs_FindObjectByName(yaffs_Object * directory,
int yaffs_ApplyToDirectoryChildren(yaffs_Object * theDir,
int (*fn) (yaffs_Object *))
{
- struct ylist_head *i;
+ struct list_head *i;
yaffs_Object *l;
if (!theDir) {
@@ -6816,9 +6730,9 @@ int yaffs_ApplyToDirectoryChildren(yaffs_Object * theDir,
YBUG();
}
- ylist_for_each(i, &theDir->variant.directoryVariant.children) {
+ list_for_each(i, &theDir->variant.directoryVariant.children) {
if (i) {
- l = ylist_entry(i, yaffs_Object, siblings);
+ l = list_entry(i, yaffs_Object, siblings);
if (l && !fn(l)) {
return YAFFS_FAIL;
}
@@ -6907,12 +6821,12 @@ int yaffs_GetObjectFileLength(yaffs_Object * obj)
int yaffs_GetObjectLinkCount(yaffs_Object * obj)
{
int count = 0;
- struct ylist_head *i;
+ struct list_head *i;
if (!obj->unlinked) {
count++; /* the object itself */
}
- ylist_for_each(i, &obj->hardLinks) {
+ list_for_each(i, &obj->hardLinks) {
count++; /* add the hard links; */
}
return count;
@@ -7135,9 +7049,8 @@ int yaffs_GutsInitialise(yaffs_Device * dev)
/* Check geometry parameters. */
- if ((!dev->inbandTags && dev->isYaffs2 && dev->totalBytesPerChunk < 1024) ||
- (!dev->isYaffs2 && dev->totalBytesPerChunk != 512) ||
- (dev->inbandTags && !dev->isYaffs2 ) ||
+ if ((dev->isYaffs2 && dev->nDataBytesPerChunk < 1024) ||
+ (!dev->isYaffs2 && dev->nDataBytesPerChunk != 512) ||
dev->nChunksPerBlock < 2 ||
dev->nReservedBlocks < 2 ||
dev->internalStartBlock <= 0 ||
@@ -7146,8 +7059,8 @@ int yaffs_GutsInitialise(yaffs_Device * dev)
) {
T(YAFFS_TRACE_ALWAYS,
(TSTR
- ("yaffs: NAND geometry problems: chunk size %d, type is yaffs%s, inbandTags %d "
- TENDSTR), dev->totalBytesPerChunk, dev->isYaffs2 ? "2" : "", dev->inbandTags));
+ ("yaffs: NAND geometry problems: chunk size %d, type is yaffs%s "
+ TENDSTR), dev->nDataBytesPerChunk, dev->isYaffs2 ? "2" : ""));
return YAFFS_FAIL;
}
@@ -7156,12 +7069,6 @@ int yaffs_GutsInitialise(yaffs_Device * dev)
(TSTR("yaffs: InitialiseNAND failed" TENDSTR)));
return YAFFS_FAIL;
}
-
- /* Sort out space for inband tags, if required */
- if(dev->inbandTags)
- dev->nDataBytesPerChunk = dev->totalBytesPerChunk - sizeof(yaffs_PackedTags2TagsPart);
- else
- dev->nDataBytesPerChunk = dev->totalBytesPerChunk;
/* Got the right mix of functions? */
if (!yaffs_CheckDevFunctions(dev)) {
@@ -7197,14 +7104,22 @@ int yaffs_GutsInitialise(yaffs_Device * dev)
/*
* Calculate all the chunk size manipulation numbers:
*/
- {
- __u32 x = dev->nDataBytesPerChunk;
- /* We always use dev->chunkShift and dev->chunkDiv */
- dev->chunkShift = Shifts(x);
- x >>= dev->chunkShift;
- dev->chunkDiv = x;
- /* We only use chunk mask if chunkDiv is 1 */
- dev->chunkMask = (1<<dev->chunkShift) - 1;
+ /* Start off assuming it is a power of 2 */
+ dev->chunkShift = ShiftDiv(dev->nDataBytesPerChunk);
+ dev->chunkMask = (1<<dev->chunkShift) - 1;
+
+ if(dev->nDataBytesPerChunk == (dev->chunkMask + 1)){
+ /* Yes it is a power of 2, disable crumbs */
+ dev->crumbMask = 0;
+ dev->crumbShift = 0;
+ dev->crumbsPerChunk = 0;
+ } else {
+ /* Not a power of 2, use crumbs instead */
+ dev->crumbShift = ShiftDiv(sizeof(yaffs_PackedTags2TagsPart));
+ dev->crumbMask = (1<<dev->crumbShift)-1;
+ dev->crumbsPerChunk = dev->nDataBytesPerChunk/(1 << dev->crumbShift);
+ dev->chunkShift = 0;
+ dev->chunkMask = 0;
}
@@ -7288,7 +7203,7 @@ int yaffs_GutsInitialise(yaffs_Device * dev)
if (!init_failed &&
dev->nShortOpCaches > 0) {
int i;
- void *buf;
+ __u8 *buf;
int srCacheBytes = dev->nShortOpCaches * sizeof(yaffs_ChunkCache);
if (dev->nShortOpCaches > YAFFS_MAX_SHORT_OP_CACHES) {
@@ -7304,7 +7219,7 @@ int yaffs_GutsInitialise(yaffs_Device * dev)
dev->srCache[i].object = NULL;
dev->srCache[i].lastUse = 0;
dev->srCache[i].dirty = 0;
- dev->srCache[i].data = buf = YMALLOC_DMA(dev->totalBytesPerChunk);
+ dev->srCache[i].data = buf = YMALLOC_DMA(dev->nDataBytesPerChunk);
}
if(!buf)
init_failed = 1;
@@ -7430,7 +7345,6 @@ void yaffs_Deinitialise(yaffs_Device * dev)
YFREE(dev->tempBuffer[i].buffer);
}
-
dev->isMounted = 0;
}
@@ -7496,7 +7410,7 @@ int yaffs_GetNumberOfFreeChunks(yaffs_Device * dev)
nFree -= ((dev->nReservedBlocks + 1) * dev->nChunksPerBlock);
/* Now we figure out how much to reserve for the checkpoint and report that... */
- blocksForCheckpoint = yaffs_CalcCheckpointBlocksRequired(dev) - dev->blocksInCheckpoint;
+ blocksForCheckpoint = dev->nCheckpointReservedBlocks - dev->blocksInCheckpoint;
if(blocksForCheckpoint < 0)
blocksForCheckpoint = 0;
@@ -7534,25 +7448,22 @@ static void yaffs_VerifyFreeChunks(yaffs_Device * dev)
/*---------------------------------------- YAFFS test code ----------------------*/
#define yaffs_CheckStruct(structure,syze, name) \
- do { \
if(sizeof(structure) != syze) \
{ \
T(YAFFS_TRACE_ALWAYS,(TSTR("%s should be %d but is %d\n" TENDSTR),\
name,syze,sizeof(structure))); \
return YAFFS_FAIL; \
- } \
- } while(0)
+ }
static int yaffs_CheckStructures(void)
{
-/* yaffs_CheckStruct(yaffs_Tags,8,"yaffs_Tags"); */
-/* yaffs_CheckStruct(yaffs_TagsUnion,8,"yaffs_TagsUnion"); */
-/* yaffs_CheckStruct(yaffs_Spare,16,"yaffs_Spare"); */
+/* yaffs_CheckStruct(yaffs_Tags,8,"yaffs_Tags") */
+/* yaffs_CheckStruct(yaffs_TagsUnion,8,"yaffs_TagsUnion") */
+/* yaffs_CheckStruct(yaffs_Spare,16,"yaffs_Spare") */
#ifndef CONFIG_YAFFS_TNODE_LIST_DEBUG
- yaffs_CheckStruct(yaffs_Tnode, 2 * YAFFS_NTNODES_LEVEL0, "yaffs_Tnode");
-#endif
-#ifndef CONFIG_YAFFS_WINCE
- yaffs_CheckStruct(yaffs_ObjectHeader, 512, "yaffs_ObjectHeader");
+ yaffs_CheckStruct(yaffs_Tnode, 2 * YAFFS_NTNODES_LEVEL0, "yaffs_Tnode")
#endif
+ yaffs_CheckStruct(yaffs_ObjectHeader, 512, "yaffs_ObjectHeader")
+
return YAFFS_OK;
}
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.h
index b9b2ea194..ea06c1a38 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_guts.h
@@ -90,7 +90,7 @@
#define YAFFS_MAX_SHORT_OP_CACHES 20
-#define YAFFS_N_TEMP_BUFFERS 6
+#define YAFFS_N_TEMP_BUFFERS 4
/* We limit the number attempts at sucessfully saving a chunk of data.
* Small-page devices have 32 pages per block; large-page devices have 64.
@@ -277,7 +277,7 @@ typedef struct {
int softDeletions:10; /* number of soft deleted pages */
int pagesInUse:10; /* number of pages in use */
- unsigned blockState:4; /* One of the above block states. NB use unsigned because enum is sometimes an int */
+ yaffs_BlockState blockState:4; /* One of the above block states */
__u32 needsRetiring:1; /* Data has failed on this block, need to get valid data off */
/* and retire the block. */
__u32 skipErasedCheck: 1; /* If this is set we can skip the erased check on this block */
@@ -303,7 +303,7 @@ typedef struct {
__u16 sum__NoLongerUsed; /* checksum of name. No longer used */
YCHAR name[YAFFS_MAX_NAME_LENGTH + 1];
- /* The following apply to directories, files, symlinks - not hard links */
+ /* Thes following apply to directories, files, symlinks - not hard links */
__u32 yst_mode; /* protection */
#ifdef CONFIG_YAFFS_WINCE
@@ -331,14 +331,11 @@ typedef struct {
__u32 win_ctime[2];
__u32 win_atime[2];
__u32 win_mtime[2];
+ __u32 roomToGrow[4];
#else
- __u32 roomToGrow[6];
-
+ __u32 roomToGrow[10];
#endif
- __u32 inbandShadowsObject;
- __u32 inbandIsShrink;
- __u32 reservedSpace[2];
int shadowsObject; /* This object header shadows the specified object if > 0 */
/* isShrink applies to object headers written when we shrink the file (ie resize) */
@@ -384,7 +381,7 @@ typedef struct {
} yaffs_FileStructure;
typedef struct {
- struct ylist_head children; /* list of child links */
+ struct list_head children; /* list of child links */
} yaffs_DirectoryStructure;
typedef struct {
@@ -427,14 +424,14 @@ struct yaffs_ObjectStruct {
struct yaffs_DeviceStruct *myDev; /* The device I'm on */
- struct ylist_head hashLink; /* list of objects in this hash bucket */
+ struct list_head hashLink; /* list of objects in this hash bucket */
- struct ylist_head hardLinks; /* all the equivalent hard linked objects */
+ struct list_head hardLinks; /* all the equivalent hard linked objects */
/* directory structure stuff */
/* also used for linking up the free list */
struct yaffs_ObjectStruct *parent;
- struct ylist_head siblings;
+ struct list_head siblings;
/* Where's my object header in NAND? */
int chunkId;
@@ -488,7 +485,7 @@ struct yaffs_ObjectList_struct {
typedef struct yaffs_ObjectList_struct yaffs_ObjectList;
typedef struct {
- struct ylist_head list;
+ struct list_head list;
int count;
} yaffs_ObjectBucket;
@@ -531,7 +528,7 @@ typedef struct {
/*----------------- Device ---------------------------------*/
struct yaffs_DeviceStruct {
- struct ylist_head devList;
+ struct list_head devList;
const char *name;
/* Entry parameters set up way early. Yaffs sets up the rest.*/
@@ -547,7 +544,7 @@ struct yaffs_DeviceStruct {
/* Stuff used by the shared space checkpointing mechanism */
/* If this value is zero, then this mechanism is disabled */
-// int nCheckpointReservedBlocks; /* Blocks to reserve for checkpoint data */
+ int nCheckpointReservedBlocks; /* Blocks to reserve for checkpoint data */
@@ -586,7 +583,7 @@ struct yaffs_DeviceStruct {
yaffs_ExtendedTags * tags);
int (*markNANDBlockBad) (struct yaffs_DeviceStruct * dev, int blockNo);
int (*queryNANDBlock) (struct yaffs_DeviceStruct * dev, int blockNo,
- yaffs_BlockState * state, __u32 *sequenceNumber);
+ yaffs_BlockState * state, int *sequenceNumber);
#endif
int isYaffs2;
@@ -601,8 +598,7 @@ struct yaffs_DeviceStruct {
void (*markSuperBlockDirty)(void * superblock);
int wideTnodesDisabled; /* Set to disable wide tnodes */
-
- YCHAR *pathDividers; /* String of legal path dividers */
+
/* End of stuff that must be set before initialisation. */
@@ -619,14 +615,16 @@ struct yaffs_DeviceStruct {
__u32 tnodeWidth;
__u32 tnodeMask;
- /* Stuff for figuring out file offset to chunk conversions */
- __u32 chunkShift; /* Shift value */
- __u32 chunkDiv; /* Divisor after shifting: 1 for power-of-2 sizes */
- __u32 chunkMask; /* Mask to use for power-of-2 case */
+ /* Stuff to support various file offses to chunk/offset translations */
+ /* "Crumbs" for nDataBytesPerChunk not being a power of 2 */
+ __u32 crumbMask;
+ __u32 crumbShift;
+ __u32 crumbsPerChunk;
+
+ /* Straight shifting for nDataBytesPerChunk being a power of 2 */
+ __u32 chunkShift;
+ __u32 chunkMask;
- /* Stuff to handle inband tags */
- int inbandTags;
- __u32 totalBytesPerChunk;
#ifdef __KERNEL__
@@ -665,8 +663,6 @@ struct yaffs_DeviceStruct {
__u32 checkpointSum;
__u32 checkpointXor;
- int nCheckpointBlocksRequired; /* Number of blocks needed to store current checkpoint set */
-
/* Block Info */
yaffs_BlockInfo *blockInfo;
__u8 *chunkBits; /* bitmap of chunks in use */
@@ -748,11 +744,9 @@ struct yaffs_DeviceStruct {
int nUnlinkedFiles; /* Count of unlinked files. */
int nBackgroundDeletions; /* Count of background deletions. */
-
- /* Temporary buffer management */
+
yaffs_TempBuffer tempBuffer[YAFFS_N_TEMP_BUFFERS];
int maxTemp;
- int tempInUse;
int unmanagedTempAllocations;
int unmanagedTempDeallocations;
@@ -764,7 +758,7 @@ struct yaffs_DeviceStruct {
typedef struct yaffs_DeviceStruct yaffs_Device;
-/* The static layout of block usage etc is stored in the super block header */
+/* The static layout of bllock usage etc is stored in the super block header */
typedef struct {
int StructType;
int version;
@@ -803,6 +797,18 @@ typedef struct {
__u32 head;
} yaffs_CheckpointValidity;
+/* Function to manipulate block info */
+static Y_INLINE yaffs_BlockInfo *yaffs_GetBlockInfo(yaffs_Device * dev, int blk)
+{
+ if (blk < dev->internalStartBlock || blk > dev->internalEndBlock) {
+ T(YAFFS_TRACE_ERROR,
+ (TSTR
+ ("**>> yaffs: getBlockInfo block %d is not valid" TENDSTR),
+ blk));
+ YBUG();
+ }
+ return &dev->blockInfo[blk - dev->internalStartBlock];
+}
/*----------------------- YAFFS Functions -----------------------*/
@@ -893,7 +899,4 @@ void yaffs_DeleteChunk(yaffs_Device * dev, int chunkId, int markNAND, int lyn);
int yaffs_CheckFF(__u8 * buffer, int nBytes);
void yaffs_HandleChunkError(yaffs_Device *dev, yaffs_BlockInfo *bi);
-__u8 *yaffs_GetTempBuffer(yaffs_Device * dev, int lineNo);
-void yaffs_ReleaseTempBuffer(yaffs_Device * dev, __u8 * buffer, int lineNo);
-
#endif
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.c
index 4888b96f6..466e5a44c 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.c
@@ -12,7 +12,7 @@
*/
const char *yaffs_mtdif_c_version =
- "$Id: yaffs_mtdif.c,v 1.21 2007-12-13 15:35:18 wookey Exp $";
+ "$Id: yaffs_mtdif.c,v 1.19 2007-02-14 01:09:06 wookey Exp $";
#include "yportenv.h"
@@ -24,7 +24,7 @@ const char *yaffs_mtdif_c_version =
#include "linux/time.h"
#include "linux/mtd/nand.h"
-#if (MTD_VERSION_CODE < MTD_VERSION(2,6,18))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
static struct nand_oobinfo yaffs_oobinfo = {
.useecc = 1,
.eccbytes = 6,
@@ -36,7 +36,7 @@ static struct nand_oobinfo yaffs_noeccinfo = {
};
#endif
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
static inline void translate_spare2oob(const yaffs_Spare *spare, __u8 *oob)
{
oob[0] = spare->tagByte0;
@@ -75,14 +75,14 @@ int nandmtd_WriteChunkToNAND(yaffs_Device * dev, int chunkInNAND,
const __u8 * data, const yaffs_Spare * spare)
{
struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
struct mtd_oob_ops ops;
#endif
size_t dummy;
int retval = 0;
loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
__u8 spareAsBytes[8]; /* OOB */
if (data && !spare)
@@ -139,14 +139,14 @@ int nandmtd_ReadChunkFromNAND(yaffs_Device * dev, int chunkInNAND, __u8 * data,
yaffs_Spare * spare)
{
struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
struct mtd_oob_ops ops;
#endif
size_t dummy;
int retval = 0;
loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
__u8 spareAsBytes[8]; /* OOB */
if (data && !spare)
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.h
index 511b0176a..317600cac 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif.h
@@ -18,11 +18,6 @@
#include "yaffs_guts.h"
-#if (MTD_VERSION_CODE < MTD_VERSION(2,6,18))
-extern struct nand_oobinfo yaffs_oobinfo;
-extern struct nand_oobinfo yaffs_noeccinfo;
-#endif
-
int nandmtd_WriteChunkToNAND(yaffs_Device * dev, int chunkInNAND,
const __u8 * data, const yaffs_Spare * spare);
int nandmtd_ReadChunkFromNAND(yaffs_Device * dev, int chunkInNAND, __u8 * data,
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1-compat.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1-compat.c
new file mode 100644
index 000000000..6a376f1f7
--- /dev/null
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1-compat.c
@@ -0,0 +1,434 @@
+From ian@brightstareng.com Fri May 18 15:06:49 2007
+From ian@brightstareng.com Fri May 18 15:08:21 2007
+Received: from 206.173.66.57.ptr.us.xo.net ([206.173.66.57] helo=zebra.brightstareng.com)
+ by apollo.linkchoose.co.uk with esmtp (Exim 4.60)
+ (envelope-from <ian@brightstareng.com>)
+ id 1Hp380-00011e-T6
+ for david.goodenough@linkchoose.co.uk; Fri, 18 May 2007 15:08:21 +0100
+Received: from localhost (localhost.localdomain [127.0.0.1])
+ by zebra.brightstareng.com (Postfix) with ESMTP
+ id 4819F28C004; Fri, 18 May 2007 10:07:49 -0400 (EDT)
+Received: from zebra.brightstareng.com ([127.0.0.1])
+ by localhost (zebra [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
+ id 05328-06; Fri, 18 May 2007 10:07:16 -0400 (EDT)
+Received: from pippin (unknown [192.168.1.25])
+ by zebra.brightstareng.com (Postfix) with ESMTP
+ id 8BEF528C1BC; Fri, 18 May 2007 10:06:53 -0400 (EDT)
+From: Ian McDonnell <ian@brightstareng.com>
+To: David Goodenough <david.goodenough@linkchoose.co.uk>
+Subject: Re: something tested this time -- yaffs_mtdif1-compat.c
+Date: Fri, 18 May 2007 10:06:49 -0400
+User-Agent: KMail/1.9.1
+References: <200705142207.06909.ian@brightstareng.com> <200705171131.53536.ian@brightstareng.com> <200705181334.32166.david.goodenough@linkchoose.co.uk>
+In-Reply-To: <200705181334.32166.david.goodenough@linkchoose.co.uk>
+Cc: Andrea Conti <alyf@alyf.net>,
+ Charles Manning <manningc2@actrix.gen.nz>
+MIME-Version: 1.0
+Content-Type: Multipart/Mixed;
+ boundary="Boundary-00=_5LbTGmt62YoutxM"
+Message-Id: <200705181006.49860.ian@brightstareng.com>
+X-Virus-Scanned: by amavisd-new at brightstareng.com
+Status: R
+X-Status: NT
+X-KMail-EncryptionState:
+X-KMail-SignatureState:
+X-KMail-MDN-Sent:
+
+--Boundary-00=_5LbTGmt62YoutxM
+Content-Type: text/plain;
+ charset="iso-8859-15"
+Content-Transfer-Encoding: 7bit
+Content-Disposition: inline
+
+David, Andrea,
+
+On Friday 18 May 2007 08:34, you wrote:
+> Yea team. With this fix in place (I put it in the wrong place
+> at first) I can now mount and ls the Yaffs partition without
+> an error messages!
+
+Good news!
+
+Attached is a newer yaffs_mtdif1.c with a bandaid to help the
+2.6.18 and 2.6.19 versions of MTD not trip on the oob read.
+See the LINUX_VERSION_CODE conditional in
+nandmtd1_ReadChunkWithTagsFromNAND.
+
+-imcd
+
+--Boundary-00=_5LbTGmt62YoutxM
+Content-Type: text/x-csrc;
+ charset="iso-8859-15";
+ name="yaffs_mtdif1.c"
+Content-Transfer-Encoding: 7bit
+Content-Disposition: attachment;
+ filename="yaffs_mtdif1.c"
+
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ * yaffs_mtdif1.c NAND mtd interface functions for small-page NAND.
+ *
+ * Copyright (C) 2002 Aleph One Ltd.
+ * for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * 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.
+ */
+
+/*
+ * This module provides the interface between yaffs_nand.c and the
+ * MTD API. This version is used when the MTD interface supports the
+ * 'mtd_oob_ops' style calls to read_oob and write_oob, circa 2.6.17,
+ * and we have small-page NAND device.
+ *
+ * These functions are invoked via function pointers in yaffs_nand.c.
+ * This replaces functionality provided by functions in yaffs_mtdif.c
+ * and the yaffs_TagsCompatability functions in yaffs_tagscompat.c that are
+ * called in yaffs_mtdif.c when the function pointers are NULL.
+ * We assume the MTD layer is performing ECC (useNANDECC is true).
+ */
+
+#include "yportenv.h"
+#include "yaffs_guts.h"
+#include "yaffs_packedtags1.h"
+#include "yaffs_tagscompat.h" // for yaffs_CalcTagsECC
+
+#include "linux/kernel.h"
+#include "linux/version.h"
+#include "linux/types.h"
+#include "linux/mtd/mtd.h"
+
+/* Don't compile this module if we don't have MTD's mtd_oob_ops interface */
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+
+const char *yaffs_mtdif1_c_version = "$Id$";
+
+#ifndef CONFIG_YAFFS_9BYTE_TAGS
+# define YTAG1_SIZE 8
+#else
+# define YTAG1_SIZE 9
+#endif
+
+#if 0
+/* Use the following nand_ecclayout with MTD when using
+ * CONFIG_YAFFS_9BYTE_TAGS and the older on-NAND tags layout.
+ * If you have existing Yaffs images and the byte order differs from this,
+ * adjust 'oobfree' to match your existing Yaffs data.
+ *
+ * This nand_ecclayout scatters/gathers to/from the old-yaffs layout with the
+ * pageStatus byte (at NAND spare offset 4) scattered/gathered from/to
+ * the 9th byte.
+ *
+ * Old-style on-NAND format: T0,T1,T2,T3,P,B,T4,T5,E0,E1,E2,T6,T7,E3,E4,E5
+ * We have/need PackedTags1 plus pageStatus: T0,T1,T2,T3,T4,T5,T6,T7,P
+ * where Tn are the tag bytes, En are MTD's ECC bytes, P is the pageStatus
+ * byte and B is the small-page bad-block indicator byte.
+ */
+static struct nand_ecclayout nand_oob_16 = {
+ .eccbytes = 6,
+ .eccpos = { 8, 9, 10, 13, 14, 15 },
+ .oobavail = 9,
+ .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
+};
+#endif
+
+/* Write a chunk (page) of data to NAND.
+ *
+ * Caller always provides ExtendedTags data which are converted to a more
+ * compact (packed) form for storage in NAND. A mini-ECC runs over the
+ * contents of the tags meta-data; used to valid the tags when read.
+ *
+ * - Pack ExtendedTags to PackedTags1 form
+ * - Compute mini-ECC for PackedTags1
+ * - Write data and packed tags to NAND.
+ *
+ * Note: Due to the use of the PackedTags1 meta-data which does not include
+ * a full sequence number (as found in the larger PackedTags2 form) it is
+ * necessary for Yaffs to re-write a chunk/page (just once) to mark it as
+ * discarded and dirty. This is not ideal: newer NAND parts are supposed
+ * to be written just once. When Yaffs performs this operation, this
+ * function is called with a NULL data pointer -- calling MTD write_oob
+ * without data is valid usage (2.6.17).
+ *
+ * Any underlying MTD error results in YAFFS_FAIL.
+ * Returns YAFFS_OK or YAFFS_FAIL.
+ */
+int nandmtd1_WriteChunkWithTagsToNAND(yaffs_Device *dev,
+ int chunkInNAND, const __u8 * data, const yaffs_ExtendedTags * etags)
+{
+ struct mtd_info * mtd = dev->genericDevice;
+ int chunkBytes = dev->nDataBytesPerChunk;
+ loff_t addr = ((loff_t)chunkInNAND) * chunkBytes;
+ struct mtd_oob_ops ops;
+ yaffs_PackedTags1 pt1;
+ int retval;
+
+ /* we assume that PackedTags1 and yaffs_Tags are compatible */
+ compile_time_assertion(sizeof(yaffs_PackedTags1) == 12);
+ compile_time_assertion(sizeof(yaffs_Tags) == 8);
+
+ yaffs_PackTags1(&pt1, etags);
+ yaffs_CalcTagsECC((yaffs_Tags *)&pt1);
+
+ /* When deleting a chunk, the upper layer provides only skeletal
+ * etags, one with chunkDeleted set. However, we need to update the
+ * tags, not erase them completely. So we use the NAND write property
+ * that only zeroed-bits stick and set tag bytes to all-ones and
+ * zero just the (not) deleted bit.
+ */
+#ifndef CONFIG_YAFFS_9BYTE_TAGS
+ if (etags->chunkDeleted) {
+ memset(&pt1, 0xff, 8);
+ /* clear delete status bit to indicate deleted */
+ pt1.deleted = 0;
+ }
+#else
+ ((__u8 *)&pt1)[8] = 0xff;
+ if (etags->chunkDeleted) {
+ memset(&pt1, 0xff, 8);
+ /* zero pageStatus byte to indicate deleted */
+ ((__u8 *)&pt1)[8] = 0;
+ }
+#endif
+
+ memset(&ops, 0, sizeof(ops));
+ ops.mode = MTD_OOB_AUTO;
+ ops.len = (data) ? chunkBytes : 0;
+ ops.ooblen = YTAG1_SIZE;
+ ops.datbuf = (__u8 *)data;
+ ops.oobbuf = (__u8 *)&pt1;
+
+ retval = mtd->write_oob(mtd, addr, &ops);
+ if (retval) {
+ yaffs_trace(YAFFS_TRACE_MTD,
+ "write_oob failed, chunk %d, mtd error %d\n",
+ chunkInNAND, retval);
+ }
+ return retval ? YAFFS_FAIL : YAFFS_OK;
+}
+
+/* Return with empty ExtendedTags but add eccResult.
+ */
+static int rettags(yaffs_ExtendedTags * etags, int eccResult, int retval)
+{
+ if (etags) {
+ memset(etags, 0, sizeof(*etags));
+ etags->eccResult = eccResult;
+ }
+ return retval;
+}
+
+/* Read a chunk (page) from NAND.
+ *
+ * Caller expects ExtendedTags data to be usable even on error; that is,
+ * all members except eccResult and blockBad are zeroed.
+ *
+ * - Check ECC results for data (if applicable)
+ * - Check for blank/erased block (return empty ExtendedTags if blank)
+ * - Check the PackedTags1 mini-ECC (correct if necessary/possible)
+ * - Convert PackedTags1 to ExtendedTags
+ * - Update eccResult and blockBad members to refect state.
+ *
+ * Returns YAFFS_OK or YAFFS_FAIL.
+ */
+int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
+ int chunkInNAND, __u8 * data, yaffs_ExtendedTags * etags)
+{
+ struct mtd_info * mtd = dev->genericDevice;
+ int chunkBytes = dev->nDataBytesPerChunk;
+ loff_t addr = ((loff_t)chunkInNAND) * chunkBytes;
+ int eccres = YAFFS_ECC_RESULT_NO_ERROR;
+ struct mtd_oob_ops ops;
+ yaffs_PackedTags1 pt1;
+ int retval;
+ int deleted;
+
+ memset(&ops, 0, sizeof(ops));
+ ops.mode = MTD_OOB_AUTO;
+ ops.len = (data) ? chunkBytes : 0;
+ ops.ooblen = YTAG1_SIZE;
+ ops.datbuf = data;
+ ops.oobbuf = (__u8 *)&pt1;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+ /* In MTD 2.6.18 to 2.6.19 nand_base.c:nand_do_read_oob() has a bug;
+ * help it out with ops.len = ops.ooblen when ops.datbuf == NULL.
+ */
+ ops.len = (ops.datbuf) ? ops.len : ops.ooblen;
+#endif
+ /* Read page and oob using MTD.
+ * Check status and determine ECC result.
+ */
+ retval = mtd->read_oob(mtd, addr, &ops);
+ if (retval) {
+ yaffs_trace(YAFFS_TRACE_MTD,
+ "read_oob failed, chunk %d, mtd error %d\n",
+ chunkInNAND, retval);
+ }
+
+ switch (retval) {
+ case 0:
+ /* no error */
+ break;
+
+ case -EUCLEAN:
+ /* MTD's ECC fixed the data */
+ eccres = YAFFS_ECC_RESULT_FIXED;
+ dev->eccFixed++;
+ break;
+
+ case -EBADMSG:
+ /* MTD's ECC could not fix the data */
+ dev->eccUnfixed++;
+ /* fall into... */
+ default:
+ rettags(etags, YAFFS_ECC_RESULT_UNFIXED, 0);
+ etags->blockBad = (mtd->block_isbad)(mtd, addr);
+ return YAFFS_FAIL;
+ }
+
+ /* Check for a blank/erased chunk.
+ */
+ if (yaffs_CheckFF((__u8 *)&pt1, 8)) {
+ /* when blank, upper layers want eccResult to be <= NO_ERROR */
+ return rettags(etags, YAFFS_ECC_RESULT_NO_ERROR, YAFFS_OK);
+ }
+
+#ifndef CONFIG_YAFFS_9BYTE_TAGS
+ /* Read deleted status (bit) then return it to it's non-deleted
+ * state before performing tags mini-ECC check. pt1.deleted is
+ * inverted.
+ */
+ deleted = !pt1.deleted;
+ pt1.deleted = 1;
+#else
+ (void) deleted; /* not used */
+#endif
+
+ /* Check the packed tags mini-ECC and correct if necessary/possible.
+ */
+ retval = yaffs_CheckECCOnTags((yaffs_Tags *)&pt1);
+ switch (retval) {
+ case 0:
+ /* no tags error, use MTD result */
+ break;
+ case 1:
+ /* recovered tags-ECC error */
+ dev->tagsEccFixed++;
+ eccres = YAFFS_ECC_RESULT_FIXED;
+ break;
+ default:
+ /* unrecovered tags-ECC error */
+ dev->tagsEccUnfixed++;
+ return rettags(etags, YAFFS_ECC_RESULT_UNFIXED, YAFFS_FAIL);
+ }
+
+ /* Unpack the tags to extended form and set ECC result.
+ * [set shouldBeFF just to keep yaffs_UnpackTags1 happy]
+ */
+ pt1.shouldBeFF = 0xFFFFFFFF;
+ yaffs_UnpackTags1(etags, &pt1);
+ etags->eccResult = eccres;
+
+ /* Set deleted state.
+ */
+#ifndef CONFIG_YAFFS_9BYTE_TAGS
+ etags->chunkDeleted = deleted;
+#else
+ etags->chunkDeleted = (yaffs_CountBits(((__u8 *)&pt1)[8]) < 7);
+#endif
+ return YAFFS_OK;
+}
+
+/* Mark a block bad.
+ *
+ * This is a persistant state.
+ * Use of this function should be rare.
+ *
+ * Returns YAFFS_OK or YAFFS_FAIL.
+ */
+int nandmtd1_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
+{
+ struct mtd_info * mtd = dev->genericDevice;
+ int blocksize = dev->nChunksPerBlock * dev->nDataBytesPerChunk;
+ int retval;
+
+ yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, "marking block %d bad", blockNo);
+
+ retval = mtd->block_markbad(mtd, (loff_t)blocksize * blockNo);
+ return (retval) ? YAFFS_FAIL : YAFFS_OK;
+}
+
+/* Check any MTD prerequists.
+ *
+ * Returns YAFFS_OK or YAFFS_FAIL.
+ */
+static int nandmtd1_TestPrerequists(struct mtd_info * mtd)
+{
+ /* 2.6.18 has mtd->ecclayout->oobavail */
+ /* 2.6.21 has mtd->ecclayout->oobavail and mtd->oobavail */
+ int oobavail = mtd->ecclayout->oobavail;
+
+ if (oobavail < YTAG1_SIZE) {
+ yaffs_trace(YAFFS_TRACE_ERROR,
+ "mtd device has only %d bytes for tags, need %d",
+ oobavail, YTAG1_SIZE);
+ return YAFFS_FAIL;
+ }
+ return YAFFS_OK;
+}
+
+/* Query for the current state of a specific block.
+ *
+ * Examine the tags of the first chunk of the block and return the state:
+ * - YAFFS_BLOCK_STATE_DEAD, the block is marked bad
+ * - YAFFS_BLOCK_STATE_NEEDS_SCANNING, the block is in use
+ * - YAFFS_BLOCK_STATE_EMPTY, the block is clean
+ *
+ * Always returns YAFFS_OK.
+ */
+int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
+ yaffs_BlockState * pState, int *pSequenceNumber)
+{
+ struct mtd_info * mtd = dev->genericDevice;
+ int chunkNo = blockNo * dev->nChunksPerBlock;
+ yaffs_ExtendedTags etags;
+ int state = YAFFS_BLOCK_STATE_DEAD;
+ int seqnum = 0;
+ int retval;
+
+ /* We don't yet have a good place to test for MTD config prerequists.
+ * Do it here as we are called during the initial scan.
+ */
+ if (nandmtd1_TestPrerequists(mtd) != YAFFS_OK) {
+ return YAFFS_FAIL;
+ }
+
+ retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags);
+ if (etags.blockBad) {
+ yaffs_trace(YAFFS_TRACE_BAD_BLOCKS,
+ "block %d is marked bad", blockNo);
+ state = YAFFS_BLOCK_STATE_DEAD;
+ }
+ else if (etags.chunkUsed) {
+ state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
+ seqnum = etags.sequenceNumber;
+ }
+ else {
+ state = YAFFS_BLOCK_STATE_EMPTY;
+ }
+
+ *pState = state;
+ *pSequenceNumber = seqnum;
+
+ /* query always succeeds */
+ return YAFFS_OK;
+}
+
+#endif /*KERNEL_VERSION*/
+
+--Boundary-00=_5LbTGmt62YoutxM--
+
+
+
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1.c
index 2b33c2cfe..36d5adec5 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif1.c
@@ -34,9 +34,9 @@
#include "linux/mtd/mtd.h"
/* Don't compile this module if we don't have MTD's mtd_oob_ops interface */
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
-const char *yaffs_mtdif1_c_version = "$Id: yaffs_mtdif1.c,v 1.7 2007-12-13 15:35:18 wookey Exp $";
+const char *yaffs_mtdif1_c_version = "$Id: yaffs_mtdif1.c,v 1.3 2007/05/15 20:16:11 ian Exp $";
#ifndef CONFIG_YAFFS_9BYTE_TAGS
# define YTAG1_SIZE 8
@@ -189,7 +189,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
ops.datbuf = data;
ops.oobbuf = (__u8 *)&pt1;
-#if (MTD_VERSION_CODE < MTD_VERSION(2,6,20))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
/* In MTD 2.6.18 to 2.6.19 nand_base.c:nand_do_read_oob() has a bug;
* help it out with ops.len = ops.ooblen when ops.datbuf == NULL.
*/
@@ -288,7 +288,7 @@ int nandmtd1_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
int blocksize = dev->nChunksPerBlock * dev->nDataBytesPerChunk;
int retval;
- yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, "marking block %d bad\n", blockNo);
+ yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, "marking block %d bad", blockNo);
retval = mtd->block_markbad(mtd, (loff_t)blocksize * blockNo);
return (retval) ? YAFFS_FAIL : YAFFS_OK;
@@ -327,7 +327,6 @@ int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
{
struct mtd_info * mtd = dev->genericDevice;
int chunkNo = blockNo * dev->nChunksPerBlock;
- loff_t addr = (loff_t)chunkNo * dev->nDataBytesPerChunk;
yaffs_ExtendedTags etags;
int state = YAFFS_BLOCK_STATE_DEAD;
int seqnum = 0;
@@ -341,16 +340,11 @@ int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
}
retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags);
- etags.blockBad = (mtd->block_isbad)(mtd, addr);
if (etags.blockBad) {
yaffs_trace(YAFFS_TRACE_BAD_BLOCKS,
- "block %d is marked bad\n", blockNo);
+ "block %d is marked bad", blockNo);
state = YAFFS_BLOCK_STATE_DEAD;
}
- else if (etags.eccResult != YAFFS_ECC_RESULT_NO_ERROR) {
- /* bad tags, need to look more closely */
- state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
- }
else if (etags.chunkUsed) {
state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
seqnum = etags.sequenceNumber;
@@ -366,4 +360,4 @@ int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
return YAFFS_OK;
}
-#endif /*MTD_VERSION*/
+#endif /*KERNEL_VERSION*/
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif2.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif2.c
index 3768b9b07..cdad0734b 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif2.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_mtdif2.c
@@ -14,7 +14,7 @@
/* mtd interface for YAFFS2 */
const char *yaffs_mtdif2_c_version =
- "$Id: yaffs_mtdif2.c,v 1.20 2008-05-05 07:58:58 charles Exp $";
+ "$Id: yaffs_mtdif2.c,v 1.17 2007-02-14 01:09:06 wookey Exp $";
#include "yportenv.h"
@@ -27,23 +27,19 @@ const char *yaffs_mtdif2_c_version =
#include "yaffs_packedtags2.h"
-/* NB For use with inband tags....
- * We assume that the data buffer is of size totalBytersPerChunk so that we can also
- * use it to load the tags.
- */
int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device * dev, int chunkInNAND,
const __u8 * data,
const yaffs_ExtendedTags * tags)
{
struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
struct mtd_oob_ops ops;
#else
size_t dummy;
#endif
int retval = 0;
- loff_t addr;
+ loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
yaffs_PackedTags2 pt;
@@ -51,42 +47,47 @@ int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device * dev, int chunkInNAND,
(TSTR
("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p"
TENDSTR), chunkInNAND, data, tags));
-
-
- addr = ((loff_t) chunkInNAND) * dev->totalBytesPerChunk;
-
- /* For yaffs2 writing there must be both data and tags.
- * If we're using inband tags, then the tags are stuffed into
- * the end of the data buffer.
- */
- if(!data || !tags)
- BUG();
- else if(dev->inbandTags){
- yaffs_PackedTags2TagsPart *pt2tp;
- pt2tp = (yaffs_PackedTags2TagsPart *)(data + dev->nDataBytesPerChunk);
- yaffs_PackTags2TagsPart(pt2tp,tags);
- }
- else
- yaffs_PackTags2(&pt, tags);
-
+
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
- ops.mode = MTD_OOB_AUTO;
- ops.ooblen = (dev->inbandTags) ? 0 : sizeof(pt);
- ops.len = dev->totalBytesPerChunk;
- ops.ooboffs = 0;
- ops.datbuf = (__u8 *)data;
- ops.oobbuf = (dev->inbandTags) ? NULL : (void *)&pt;
- retval = mtd->write_oob(mtd, addr, &ops);
+ if (tags)
+ yaffs_PackTags2(&pt, tags);
+ else
+ BUG(); /* both tags and data should always be present */
+ if (data) {
+ ops.mode = MTD_OOB_AUTO;
+ ops.ooblen = sizeof(pt);
+ ops.len = dev->nDataBytesPerChunk;
+ ops.ooboffs = 0;
+ ops.datbuf = (__u8 *)data;
+ ops.oobbuf = (void *)&pt;
+ retval = mtd->write_oob(mtd, addr, &ops);
+ } else
+ BUG(); /* both tags and data should always be present */
#else
- if (!dev->inbandTags) {
- retval =
- mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk,
- &dummy, data, (__u8 *) & pt, NULL);
+ if (tags) {
+ yaffs_PackTags2(&pt, tags);
+ }
+
+ if (data && tags) {
+ if (dev->useNANDECC)
+ retval =
+ mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk,
+ &dummy, data, (__u8 *) & pt, NULL);
+ else
+ retval =
+ mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk,
+ &dummy, data, (__u8 *) & pt, NULL);
} else {
- retval =
- mtd->write(mtd, addr, dev->totalBytesPerChunk, &dummy,
- data);
+ if (data)
+ retval =
+ mtd->write(mtd, addr, dev->nDataBytesPerChunk, &dummy,
+ data);
+ if (tags)
+ retval =
+ mtd->write_oob(mtd, addr, mtd->oobsize, &dummy,
+ (__u8 *) & pt);
+
}
#endif
@@ -100,12 +101,11 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
__u8 * data, yaffs_ExtendedTags * tags)
{
struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
struct mtd_oob_ops ops;
#endif
size_t dummy;
int retval = 0;
- int localData = 0;
loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
@@ -115,21 +115,10 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
(TSTR
("nandmtd2_ReadChunkWithTagsFromNAND chunk %d data %p tags %p"
TENDSTR), chunkInNAND, data, tags));
-
- if(dev->inbandTags){
-
- if(!data) {
- localData = 1;
- data = yaffs_GetTempBuffer(dev,__LINE__);
- }
-
-
- }
-
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
- if (dev->inbandTags || (data && !tags))
- retval = mtd->read(mtd, addr, dev->totalBytesPerChunk,
+ if (data && !tags)
+ retval = mtd->read(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data);
else if (tags) {
ops.mode = MTD_OOB_AUTO;
@@ -141,43 +130,38 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
retval = mtd->read_oob(mtd, addr, &ops);
}
#else
- if (!dev->inbandTags && data && tags) {
-
- retval = mtd->read_ecc(mtd, addr, dev->nDataBytesPerChunk,
+ if (data && tags) {
+ if (dev->useNANDECC) {
+ retval =
+ mtd->read_ecc(mtd, addr, dev->nDataBytesPerChunk,
&dummy, data, dev->spareBuffer,
NULL);
+ } else {
+ retval =
+ mtd->read_ecc(mtd, addr, dev->nDataBytesPerChunk,
+ &dummy, data, dev->spareBuffer,
+ NULL);
+ }
} else {
if (data)
retval =
mtd->read(mtd, addr, dev->nDataBytesPerChunk, &dummy,
data);
- if (!dev->inbandTags && tags)
+ if (tags)
retval =
mtd->read_oob(mtd, addr, mtd->oobsize, &dummy,
dev->spareBuffer);
}
#endif
+ memcpy(&pt, dev->spareBuffer, sizeof(pt));
- if(dev->inbandTags){
- if(tags){
- yaffs_PackedTags2TagsPart * pt2tp;
- pt2tp = (yaffs_PackedTags2TagsPart *)&data[dev->nDataBytesPerChunk];
- yaffs_UnpackTags2TagsPart(tags,pt2tp);
- }
- }
- else {
- if (tags){
- memcpy(&pt, dev->spareBuffer, sizeof(pt));
- yaffs_UnpackTags2(tags, &pt);
- }
- }
+ if (tags)
+ yaffs_UnpackTags2(tags, &pt);
- if(localData)
- yaffs_ReleaseTempBuffer(dev,data,__LINE__);
-
if(tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR)
- tags->eccResult = YAFFS_ECC_RESULT_UNFIXED;
+ tags->eccResult = YAFFS_ECC_RESULT_UNFIXED;
+
if (retval == 0)
return YAFFS_OK;
else
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nand.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nand.c
index af4215772..4e250338d 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nand.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nand.c
@@ -12,13 +12,12 @@
*/
const char *yaffs_nand_c_version =
- "$Id: yaffs_nand.c,v 1.9 2008-05-05 07:58:58 charles Exp $";
+ "$Id: yaffs_nand.c,v 1.7 2007-02-14 01:09:06 wookey Exp $";
#include "yaffs_nand.h"
#include "yaffs_tagscompat.h"
#include "yaffs_tagsvalidity.h"
-#include "yaffs_getblockinfo.h"
int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
__u8 * buffer,
@@ -99,7 +98,7 @@ int yaffs_MarkBlockBad(yaffs_Device * dev, int blockNo)
int yaffs_QueryInitialBlockState(yaffs_Device * dev,
int blockNo,
yaffs_BlockState * state,
- __u32 *sequenceNumber)
+ unsigned *sequenceNumber)
{
blockNo -= dev->blockOffset;
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nandemul2k.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nandemul2k.h
index c8576b307..cd2e96f7a 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nandemul2k.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_nandemul2k.h
@@ -22,13 +22,13 @@
int nandemul2k_WriteChunkWithTagsToNAND(struct yaffs_DeviceStruct *dev,
int chunkInNAND, const __u8 * data,
- const yaffs_ExtendedTags * tags);
+ yaffs_ExtendedTags * tags);
int nandemul2k_ReadChunkWithTagsFromNAND(struct yaffs_DeviceStruct *dev,
int chunkInNAND, __u8 * data,
yaffs_ExtendedTags * tags);
int nandemul2k_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo);
int nandemul2k_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
- yaffs_BlockState * state, __u32 *sequenceNumber);
+ yaffs_BlockState * state, int *sequenceNumber);
int nandemul2k_EraseBlockInNAND(struct yaffs_DeviceStruct *dev,
int blockInNAND);
int nandemul2k_InitialiseNAND(struct yaffs_DeviceStruct *dev);
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.c
index 957ed8bf0..e420f95da 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.c
@@ -37,70 +37,60 @@
#define EXTRA_OBJECT_TYPE_SHIFT (28)
#define EXTRA_OBJECT_TYPE_MASK ((0x0F) << EXTRA_OBJECT_TYPE_SHIFT)
-
-static void yaffs_DumpPackedTags2TagsPart(const yaffs_PackedTags2TagsPart * ptt)
+static void yaffs_DumpPackedTags2(const yaffs_PackedTags2 * pt)
{
T(YAFFS_TRACE_MTD,
(TSTR("packed tags obj %d chunk %d byte %d seq %d" TENDSTR),
- ptt->objectId, ptt->chunkId, ptt->byteCount,
- ptt->sequenceNumber));
-}
-static void yaffs_DumpPackedTags2(const yaffs_PackedTags2 * pt)
-{
- yaffs_DumpPackedTags2TagsPart(&pt->t);
+ pt->t.objectId, pt->t.chunkId, pt->t.byteCount,
+ pt->t.sequenceNumber));
}
static void yaffs_DumpTags2(const yaffs_ExtendedTags * t)
{
T(YAFFS_TRACE_MTD,
(TSTR
- ("ext.tags eccres %d blkbad %d chused %d obj %d chunk%d byte %d del %d ser %d seq %d"
+ ("ext.tags eccres %d blkbad %d chused %d obj %d chunk%d byte "
+ "%d del %d ser %d seq %d"
TENDSTR), t->eccResult, t->blockBad, t->chunkUsed, t->objectId,
t->chunkId, t->byteCount, t->chunkDeleted, t->serialNumber,
t->sequenceNumber));
}
-void yaffs_PackTags2TagsPart(yaffs_PackedTags2TagsPart * ptt, const yaffs_ExtendedTags * t)
+void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t)
{
- ptt->chunkId = t->chunkId;
- ptt->sequenceNumber = t->sequenceNumber;
- ptt->byteCount = t->byteCount;
- ptt->objectId = t->objectId;
+ pt->t.chunkId = t->chunkId;
+ pt->t.sequenceNumber = t->sequenceNumber;
+ pt->t.byteCount = t->byteCount;
+ pt->t.objectId = t->objectId;
if (t->chunkId == 0 && t->extraHeaderInfoAvailable) {
/* Store the extra header info instead */
/* We save the parent object in the chunkId */
- ptt->chunkId = EXTRA_HEADER_INFO_FLAG
+ pt->t.chunkId = EXTRA_HEADER_INFO_FLAG
| t->extraParentObjectId;
if (t->extraIsShrinkHeader) {
- ptt->chunkId |= EXTRA_SHRINK_FLAG;
+ pt->t.chunkId |= EXTRA_SHRINK_FLAG;
}
if (t->extraShadows) {
- ptt->chunkId |= EXTRA_SHADOWS_FLAG;
+ pt->t.chunkId |= EXTRA_SHADOWS_FLAG;
}
- ptt->objectId &= ~EXTRA_OBJECT_TYPE_MASK;
- ptt->objectId |=
+ pt->t.objectId &= ~EXTRA_OBJECT_TYPE_MASK;
+ pt->t.objectId |=
(t->extraObjectType << EXTRA_OBJECT_TYPE_SHIFT);
if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK) {
- ptt->byteCount = t->extraEquivalentObjectId;
+ pt->t.byteCount = t->extraEquivalentObjectId;
} else if (t->extraObjectType == YAFFS_OBJECT_TYPE_FILE) {
- ptt->byteCount = t->extraFileLength;
+ pt->t.byteCount = t->extraFileLength;
} else {
- ptt->byteCount = 0;
+ pt->t.byteCount = 0;
}
}
- yaffs_DumpPackedTags2TagsPart(ptt);
+ yaffs_DumpPackedTags2(pt);
yaffs_DumpTags2(t);
-}
-
-
-void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t)
-{
- yaffs_PackTags2TagsPart(&pt->t,t);
#ifndef YAFFS_IGNORE_TAGS_ECC
{
@@ -111,60 +101,13 @@ void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t)
#endif
}
-
-void yaffs_UnpackTags2TagsPart(yaffs_ExtendedTags * t, yaffs_PackedTags2TagsPart * ptt)
+void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt)
{
memset(t, 0, sizeof(yaffs_ExtendedTags));
yaffs_InitialiseTags(t);
- if (ptt->sequenceNumber != 0xFFFFFFFF) {
- t->blockBad = 0;
- t->chunkUsed = 1;
- t->objectId = ptt->objectId;
- t->chunkId = ptt->chunkId;
- t->byteCount = ptt->byteCount;
- t->chunkDeleted = 0;
- t->serialNumber = 0;
- t->sequenceNumber = ptt->sequenceNumber;
-
- /* Do extra header info stuff */
-
- if (ptt->chunkId & EXTRA_HEADER_INFO_FLAG) {
- t->chunkId = 0;
- t->byteCount = 0;
-
- t->extraHeaderInfoAvailable = 1;
- t->extraParentObjectId =
- ptt->chunkId & (~(ALL_EXTRA_FLAGS));
- t->extraIsShrinkHeader =
- (ptt->chunkId & EXTRA_SHRINK_FLAG) ? 1 : 0;
- t->extraShadows =
- (ptt->chunkId & EXTRA_SHADOWS_FLAG) ? 1 : 0;
- t->extraObjectType =
- ptt->objectId >> EXTRA_OBJECT_TYPE_SHIFT;
- t->objectId &= ~EXTRA_OBJECT_TYPE_MASK;
-
- if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK) {
- t->extraEquivalentObjectId = ptt->byteCount;
- } else {
- t->extraFileLength = ptt->byteCount;
- }
- }
- }
-
- yaffs_DumpPackedTags2TagsPart(ptt);
- yaffs_DumpTags2(t);
-
-}
-
-
-void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt)
-{
-
- yaffs_UnpackTags2TagsPart(t,&pt->t);
-
if (pt->t.sequenceNumber != 0xFFFFFFFF) {
/* Page is in use */
#ifdef YAFFS_IGNORE_TAGS_ECC
@@ -199,10 +142,41 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt)
}
}
#endif
+ t->blockBad = 0;
+ t->chunkUsed = 1;
+ t->objectId = pt->t.objectId;
+ t->chunkId = pt->t.chunkId;
+ t->byteCount = pt->t.byteCount;
+ t->chunkDeleted = 0;
+ t->serialNumber = 0;
+ t->sequenceNumber = pt->t.sequenceNumber;
+
+ /* Do extra header info stuff */
+
+ if (pt->t.chunkId & EXTRA_HEADER_INFO_FLAG) {
+ t->chunkId = 0;
+ t->byteCount = 0;
+
+ t->extraHeaderInfoAvailable = 1;
+ t->extraParentObjectId =
+ pt->t.chunkId & (~(ALL_EXTRA_FLAGS));
+ t->extraIsShrinkHeader =
+ (pt->t.chunkId & EXTRA_SHRINK_FLAG) ? 1 : 0;
+ t->extraShadows =
+ (pt->t.chunkId & EXTRA_SHADOWS_FLAG) ? 1 : 0;
+ t->extraObjectType =
+ pt->t.objectId >> EXTRA_OBJECT_TYPE_SHIFT;
+ t->objectId &= ~EXTRA_OBJECT_TYPE_MASK;
+
+ if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK) {
+ t->extraEquivalentObjectId = pt->t.byteCount;
+ } else {
+ t->extraFileLength = pt->t.byteCount;
+ }
+ }
}
yaffs_DumpPackedTags2(pt);
yaffs_DumpTags2(t);
}
-
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.h
index 75761d333..c2242ffe7 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_packedtags2.h
@@ -33,11 +33,6 @@ typedef struct {
yaffs_ECCOther ecc;
} yaffs_PackedTags2;
-/* Full packed tags with ECC, used for oob tags */
void yaffs_PackTags2(yaffs_PackedTags2 * pt, const yaffs_ExtendedTags * t);
void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt);
-
-/* Only the tags part (no ECC for use with inband tags */
-void yaffs_PackTags2TagsPart(yaffs_PackedTags2TagsPart * pt, const yaffs_ExtendedTags * t);
-void yaffs_UnpackTags2TagsPart(yaffs_ExtendedTags * t, yaffs_PackedTags2TagsPart * pt);
#endif
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.c b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.c
index ab756d06d..7622b1af7 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.c
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.c
@@ -14,7 +14,6 @@
#include "yaffs_guts.h"
#include "yaffs_tagscompat.h"
#include "yaffs_ecc.h"
-#include "yaffs_getblockinfo.h"
static void yaffs_HandleReadDataError(yaffs_Device * dev, int chunkInNAND);
#ifdef NOTYET
@@ -439,7 +438,7 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev,
yaffs_ECCResult eccResult;
static yaffs_Spare spareFF;
- static int init = 0;
+ static int init;
if (!init) {
memset(&spareFF, 0xFF, sizeof(spareFF));
@@ -498,9 +497,9 @@ int yaffs_TagsCompatabilityMarkNANDBlockBad(struct yaffs_DeviceStruct *dev,
}
int yaffs_TagsCompatabilityQueryNANDBlock(struct yaffs_DeviceStruct *dev,
- int blockNo,
- yaffs_BlockState *state,
- __u32 *sequenceNumber)
+ int blockNo, yaffs_BlockState *
+ state,
+ int *sequenceNumber)
{
yaffs_Spare spare0, spare1;
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.h
index 6549398ee..a61e3ba14 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yaffs_tagscompat.h
@@ -30,9 +30,8 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev,
int yaffs_TagsCompatabilityMarkNANDBlockBad(struct yaffs_DeviceStruct *dev,
int blockNo);
int yaffs_TagsCompatabilityQueryNANDBlock(struct yaffs_DeviceStruct *dev,
- int blockNo,
- yaffs_BlockState *state,
- __u32 *sequenceNumber);
+ int blockNo, yaffs_BlockState *
+ state, int *sequenceNumber);
void yaffs_CalcTagsECC(yaffs_Tags * tags);
int yaffs_CheckECCOnTags(yaffs_Tags * tags);
diff --git a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yportenv.h b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yportenv.h
index 097b2a675..15ac28121 100644
--- a/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yportenv.h
+++ b/target/linux/generic-2.6/files-2.6.25/fs/yaffs2/yportenv.h
@@ -17,14 +17,6 @@
#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.
- */
-
-#define MTD_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-
#if defined CONFIG_YAFFS_WINCE
#include "ywinceenv.h"
@@ -34,10 +26,7 @@
#include "moduleconfig.h"
/* Linux kernel */
-
#include <linux/version.h>
-#define MTD_VERSION_CODE LINUX_VERSION_CODE
-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
#include <linux/config.h>
#endif
@@ -101,8 +90,6 @@
#elif defined CONFIG_YAFFS_DIRECT
-#define MTD_VERSION_CODE MTD_VERSION(2,6,22)
-
/* Direct interface */
#include "ydirectenv.h"
@@ -193,8 +180,8 @@ extern unsigned int yaffs_wr_attempts;
#define T(mask,p) do{ if((mask) & (yaffs_traceMask | YAFFS_TRACE_ALWAYS)) TOUT(p);} while(0)
-#ifndef YBUG
-#define YBUG() do {T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__));} while(0)
+#ifndef CONFIG_YAFFS_WINCE
+#define YBUG() T(YAFFS_TRACE_BUG,(TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),__LINE__))
#endif
#endif