yaffs: More clean up
[yaffs2.git] / yaffs_vfs_single.c
index 0a7c85c970abbc76010adff1ac81d5ed96b67b32..cb5968f24c0d6638fa7e6301951ffeb8fb15de75 100644 (file)
@@ -297,14 +297,14 @@ static unsigned yaffs_gc_control_callback(struct yaffs_dev *dev)
 static void yaffs_gross_lock(struct yaffs_dev *dev)
 {
        T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current));
-       down(&(struct yaffs_devo_lc(dev)->gross_lock));
+       down(&(yaffs_dev_to_lc(dev)->gross_lock));
        T(YAFFS_TRACE_LOCK, (TSTR("yaffs locked %p\n"), current));
 }
 
 static void yaffs_gross_unlock(struct yaffs_dev *dev)
 {
        T(YAFFS_TRACE_LOCK, (TSTR("yaffs unlocking %p\n"), current));
-       up(&(struct yaffs_devo_lc(dev)->gross_lock));
+       up(&(yaffs_dev_to_lc(dev)->gross_lock));
 }
 
 
@@ -395,7 +395,7 @@ struct yaffs_search_context {
        struct yaffs_dev *dev;
        struct yaffs_obj *dir_obj;
        struct yaffs_obj *next_return;
-       struct ylist_head others;
+       struct list_head others;
 };
 
 /*
@@ -411,14 +411,14 @@ static struct yaffs_search_context * yaffs_new_search(struct yaffs_obj *dir)
        if(sc){
                sc->dir_obj = dir;
                sc->dev = dev;
-               if( ylist_empty(&sc->dir_obj->variant.dir_variant.children))
+               if( list_empty(&sc->dir_obj->variant.dir_variant.children))
                        sc->next_return = NULL;
                else
-                       sc->next_return = ylist_entry(
+                       sc->next_return = list_entry(
                                 dir->variant.dir_variant.children.next,
                                struct yaffs_obj,siblings);
-               YINIT_LIST_HEAD(&sc->others);
-               ylist_add(&sc->others,&(struct yaffs_devo_lc(dev)->search_contexts));
+               INIT_LIST_HEAD(&sc->others);
+               list_add(&sc->others,&(yaffs_dev_to_lc(dev)->search_contexts));
        }
        return sc;
 }
@@ -429,7 +429,7 @@ static struct yaffs_search_context * yaffs_new_search(struct yaffs_obj *dir)
 static void yaffs_search_end(struct yaffs_search_context * sc)
 {
        if(sc){
-               ylist_del(&sc->others);
+               list_del(&sc->others);
                YFREE(sc);
        }
 }
@@ -445,15 +445,15 @@ static void yaffs_search_advance(struct yaffs_search_context *sc)
                 return;
 
         if( sc->next_return == NULL ||
-                ylist_empty(&sc->dir_obj->variant.dir_variant.children))
+                list_empty(&sc->dir_obj->variant.dir_variant.children))
                 sc->next_return = NULL;
         else {
-                struct ylist_head *next = sc->next_return->siblings.next;
+                struct list_head *next = sc->next_return->siblings.next;
 
                 if( next == &sc->dir_obj->variant.dir_variant.children)
                         sc->next_return = NULL; /* end of list */
                 else
-                        sc->next_return = ylist_entry(next,struct yaffs_obj,siblings);
+                        sc->next_return = list_entry(next,struct yaffs_obj,siblings);
         }
 }
 
@@ -465,18 +465,18 @@ static void yaffs_search_advance(struct yaffs_search_context *sc)
 static void yaffs_remove_obj_callback(struct yaffs_obj *obj)
 {
 
-        struct ylist_head *i;
+        struct list_head *i;
         struct yaffs_search_context *sc;
-        struct ylist_head *search_contexts = &(struct yaffs_devo_lc(obj->my_dev)->search_contexts);
+        struct list_head *search_contexts = &(yaffs_dev_to_lc(obj->my_dev)->search_contexts);
 
 
         /* Iterate through the directory search contexts.
          * If any are currently on the object being removed, then advance
          * the search context to the next object to prevent a hanging pointer.
          */
-         ylist_for_each(i, search_contexts) {
+         list_for_each(i, search_contexts) {
                 if (i) {
-                        sc = ylist_entry(i, struct yaffs_search_context,others);
+                        sc = list_entry(i, struct yaffs_search_context,others);
                         if(sc->next_return == obj)
                                 yaffs_search_advance(sc);
                 }
@@ -550,7 +550,7 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
 
        struct yaffs_dev *dev = yaffs_inode_to_obj(dir)->my_dev;
 
-       if(current != struct yaffs_devo_lc(dev)->readdir_process)
+       if(current != yaffs_dev_to_lc(dev)->readdir_process)
                yaffs_gross_lock(dev);
 
        T(YAFFS_TRACE_OS,
@@ -563,7 +563,7 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
        obj = yaffs_get_equivalent_obj(obj);    /* in case it was a hardlink */
 
        /* Can't hold gross lock when calling yaffs_get_inode() */
-       if(current != struct yaffs_devo_lc(dev)->readdir_process)
+       if(current != yaffs_dev_to_lc(dev)->readdir_process)
                yaffs_gross_unlock(dev);
 
        if (obj) {
@@ -1187,7 +1187,7 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
 
        yaffs_gross_lock(dev);
 
-       struct yaffs_devo_lc(dev)->readdir_process = current;
+       yaffs_dev_to_lc(dev)->readdir_process = current;
 
        offset = f->f_pos;
 
@@ -1272,7 +1272,7 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
 
 out:
        yaffs_search_end(sc);
-       struct yaffs_devo_lc(dev)->readdir_process = NULL;
+       yaffs_dev_to_lc(dev)->readdir_process = NULL;
        yaffs_gross_unlock(dev);
 
        return ret_val;
@@ -1527,7 +1527,7 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 
        if (target && target->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY &&
-               !ylist_empty(&target->variant.dir_variant.children)) {
+               !list_empty(&target->variant.dir_variant.children)) {
 
                T(YAFFS_TRACE_OS, (TSTR("target is non-empty dir\n")));
 
@@ -1818,7 +1818,7 @@ static void yaffs_flush_super(struct super_block *sb, int do_checkpoint)
 static unsigned yaffs_bg_gc_urgency(struct yaffs_dev *dev)
 {
        unsigned erased_chunks = dev->n_erased_blocks * dev->param.chunks_per_block;
-       struct yaffs_linux_context *context = struct yaffs_devo_lc(dev);
+       struct yaffs_linux_context *context = yaffs_dev_to_lc(dev);
        unsigned scattered = 0; /* Free chunks not in an erased block */
 
        if(erased_chunks < dev->n_free_chunks)
@@ -1889,7 +1889,7 @@ void yaffs_background_waker(unsigned long data)
 static int yaffs_bg_thread_fn(void *data)
 {
        struct yaffs_dev *dev = (struct yaffs_dev *)data;
-       struct yaffs_linux_context *context = struct yaffs_devo_lc(dev);
+       struct yaffs_linux_context *context = yaffs_dev_to_lc(dev);
        unsigned long now = jiffies;
        unsigned long next_dir_update = now;
        unsigned long next_gc = now;
@@ -1963,7 +1963,7 @@ static int yaffs_bg_thread_fn(void *data)
 static int yaffs_bg_start(struct yaffs_dev *dev)
 {
        int retval = 0;
-       struct yaffs_linux_context *context = struct yaffs_devo_lc(dev);
+       struct yaffs_linux_context *context = yaffs_dev_to_lc(dev);
 
        if(dev->read_only)
                return -1;
@@ -1983,7 +1983,7 @@ static int yaffs_bg_start(struct yaffs_dev *dev)
 
 static void yaffs_bg_stop(struct yaffs_dev *dev)
 {
-       struct yaffs_linux_context *ctxt = struct yaffs_devo_lc(dev);
+       struct yaffs_linux_context *ctxt = yaffs_dev_to_lc(dev);
 
        ctxt->bg_running = 0;
 
@@ -2052,7 +2052,7 @@ static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino)
        return inode;
 }
 
-static YLIST_HEAD(yaffs_context_list);
+static LIST_HEAD(yaffs_context_list);
 struct semaphore yaffs_context_lock;
 
 static void yaffs_put_super(struct super_block *sb)
@@ -2071,8 +2071,8 @@ static void yaffs_put_super(struct super_block *sb)
 
        yaffs_flush_super(sb,1);
 
-       if (struct yaffs_devo_lc(dev)->put_super_fn)
-               struct yaffs_devo_lc(dev)->put_super_fn(sb);
+       if (yaffs_dev_to_lc(dev)->put_super_fn)
+               yaffs_dev_to_lc(dev)->put_super_fn(sb);
 
 
        yaffs_deinitialise(dev);
@@ -2080,12 +2080,12 @@ static void yaffs_put_super(struct super_block *sb)
        yaffs_gross_unlock(dev);
 
        down(&yaffs_context_lock);
-       ylist_del_init(&(struct yaffs_devo_lc(dev)->context_list));
+       list_del_init(&(yaffs_dev_to_lc(dev)->context_list));
        up(&yaffs_context_lock);
 
-       if (struct yaffs_devo_lc(dev)->spare_buffer) {
-               YFREE(struct yaffs_devo_lc(dev)->spare_buffer);
-               struct yaffs_devo_lc(dev)->spare_buffer = NULL;
+       if (yaffs_dev_to_lc(dev)->spare_buffer) {
+               YFREE(yaffs_dev_to_lc(dev)->spare_buffer);
+               yaffs_dev_to_lc(dev)->spare_buffer = NULL;
        }
 
        kfree(dev);
@@ -2094,7 +2094,7 @@ static void yaffs_put_super(struct super_block *sb)
 
 static void yaffs_mtd_put_super(struct super_block *sb)
 {
-       struct mtd_info *mtd = struct yaffs_devo_mtd(yaffs_super_to_dev(sb));
+       struct mtd_info *mtd = yaffs_dev_to_mtd(yaffs_super_to_dev(sb));
 
        if (mtd->sync)
                mtd->sync(mtd);
@@ -2105,14 +2105,14 @@ static void yaffs_mtd_put_super(struct super_block *sb)
 
 static void yaffs_touch_super(struct yaffs_dev *dev)
 {
-       struct super_block *sb = struct yaffs_devo_lc(dev)->super;
+       struct super_block *sb = yaffs_dev_to_lc(dev)->super;
 
        T(YAFFS_TRACE_OS, (TSTR("yaffs_touch_super() sb = %p\n"), sb));
        if (sb)
                sb->s_dirt = 1;
 }
 
-typedef struct {
+struct yaffs_options {
        int inband_tags;
        int skip_checkpoint_read;
        int skip_checkpoint_write;
@@ -2123,10 +2123,10 @@ typedef struct {
        int lazy_loading_overridden;
        int empty_lost_and_found;
        int empty_lost_and_found_overridden;
-} yaffs_options;
+} ;
 
 #define MAX_OPT_LEN 30
-static int yaffs_parse_options(yaffs_options *options, const char *options_str)
+static int yaffs_parse_options(struct yaffs_options *options, const char *options_str)
 {
        char cur_opt[MAX_OPT_LEN + 1];
        int p;
@@ -2205,12 +2205,12 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
 
        int read_only = 0;
 
-       yaffs_options options;
+       struct yaffs_options options;
 
        unsigned mount_id;
        int found;
        struct yaffs_linux_context *context_iterator;
-       struct ylist_head *l;
+       struct list_head *l;
 
        sb->s_magic = YAFFS_MAGIC;
        sb->s_op = &yaffs_super_ops;
@@ -2386,7 +2386,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
 
        memset(context,0,sizeof(struct yaffs_linux_context));
        dev->os_context = context;
-       YINIT_LIST_HEAD(&(context->context_list));
+       INIT_LIST_HEAD(&(context->context_list));
        context->dev = dev;
        context->super = sb;
 
@@ -2455,7 +2455,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
                    nandmtd2_read_chunk_tags;
                param->bad_block_fn = nandmtd2_mark_block_bad;
                param->query_block_fn = nandmtd2_query_block;
-               struct yaffs_devo_lc(dev)->spare_buffer = YMALLOC(mtd->oobsize);
+               yaffs_dev_to_lc(dev)->spare_buffer = YMALLOC(mtd->oobsize);
                param->is_yaffs2 = 1;
                param->total_bytes_per_chunk = mtd->writesize;
                param->chunks_per_block = mtd->erasesize / mtd->writesize;
@@ -2477,12 +2477,12 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        param->erase_fn = nandmtd_erase_block;
        param->initialise_flash_fn = nandmtd_initialise;
 
-       struct yaffs_devo_lc(dev)->put_super_fn = yaffs_mtd_put_super;
+       yaffs_dev_to_lc(dev)->put_super_fn = yaffs_mtd_put_super;
 
        param->sb_dirty_fn = yaffs_touch_super;
        param->gc_control = yaffs_gc_control_callback;
 
-       struct yaffs_devo_lc(dev)->super= sb;
+       yaffs_dev_to_lc(dev)->super= sb;
        
 
 #ifndef CONFIG_YAFFS_DOES_ECC
@@ -2501,22 +2501,22 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        found = 0;
        for(mount_id=0; ! found; mount_id++){
                found = 1;
-               ylist_for_each(l,&yaffs_context_list){
-                       context_iterator = ylist_entry(l,struct yaffs_linux_context,context_list);
+               list_for_each(l,&yaffs_context_list){
+                       context_iterator = list_entry(l,struct yaffs_linux_context,context_list);
                        if(context_iterator->mount_id == mount_id)
                                found = 0;
                }
        }
        context->mount_id = mount_id;
 
-       ylist_add_tail(&(struct yaffs_devo_lc(dev)->context_list), &yaffs_context_list);
+       list_add_tail(&(yaffs_dev_to_lc(dev)->context_list), &yaffs_context_list);
        up(&yaffs_context_lock);
 
         /* Directory search handling...*/
-        YINIT_LIST_HEAD(&(struct yaffs_devo_lc(dev)->search_contexts));
+        INIT_LIST_HEAD(&(yaffs_dev_to_lc(dev)->search_contexts));
         param->remove_obj_fn = yaffs_remove_obj_callback;
 
-       init_MUTEX(&(struct yaffs_devo_lc(dev)->gross_lock));
+       init_MUTEX(&(yaffs_dev_to_lc(dev)->gross_lock));
 
        yaffs_gross_lock(dev);
 
@@ -2682,7 +2682,7 @@ static int yaffs_proc_read(char *page,
                           char **start,
                           off_t offset, int count, int *eof, void *data)
 {
-       struct ylist_head *item;
+       struct list_head *item;
        char *buf = page;
        int step = offset;
        int n = 0;
@@ -2706,8 +2706,8 @@ static int yaffs_proc_read(char *page,
                down(&yaffs_context_lock);
 
                /* Locate and print the Nth entry.  Order N-squared but N is small. */
-               ylist_for_each(item, &yaffs_context_list) {
-                       struct yaffs_linux_context *dc = ylist_entry(item, struct yaffs_linux_context, context_list);
+               list_for_each(item, &yaffs_context_list) {
+                       struct yaffs_linux_context *dc = list_entry(item, struct yaffs_linux_context, context_list);
                        struct yaffs_dev *dev = dc->dev;
 
                        if (n < (step & ~1)) {
@@ -2732,15 +2732,15 @@ static int yaffs_stats_proc_read(char *page,
                                char **start,
                                off_t offset, int count, int *eof, void *data)
 {
-       struct ylist_head *item;
+       struct list_head *item;
        char *buf = page;
        int n = 0;
 
        down(&yaffs_context_lock);
 
        /* Locate and print the Nth entry.  Order N-squared but N is small. */
-       ylist_for_each(item, &yaffs_context_list) {
-               struct yaffs_linux_context *dc = ylist_entry(item, struct yaffs_linux_context, context_list);
+       list_for_each(item, &yaffs_context_list) {
+               struct yaffs_linux_context *dc = list_entry(item, struct yaffs_linux_context, context_list);
                struct yaffs_dev *dev = dc->dev;
 
                int erased_chunks;