Clean ups
authorCharles Manning <cdhmanning@gmail.com>
Thu, 21 Jun 2012 02:29:02 +0000 (14:29 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 21 Jun 2012 02:29:02 +0000 (14:29 +1200)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs_guts.c
yaffs_guts.h
yaffs_linux.h
yaffs_nand.c
yaffs_nand.h
yaffs_vfs_multi.c
yaffs_vfs_single.c

index 66e8c5ec41a4326e2f932aad6d6aa861b6d4ec00..14ab47219674ff8f5abf3fd4cb3e3228f0a5a4d8 100644 (file)
@@ -2798,7 +2798,8 @@ static int yaffs_check_gc(struct yaffs_dev *dev, int background)
        int erased_chunks;
        int checkpt_block_adjust;
 
-       if (dev->param.gc_control && (dev->param.gc_control(dev) & 1) == 0)
+       if (dev->param.gc_control_fn &&
+               (dev->param.gc_control_fn(dev) & 1) == 0)
                return YAFFS_OK;
 
        if (dev->gc_disable)
@@ -4537,12 +4538,15 @@ static int yaffs_check_dev_fns(struct yaffs_dev *dev)
        struct yaffs_param *param = &dev->param;
 
        /* Common functions, gotta have */
-       if (!param->drv_initialise_fn ||
-           !param->drv_read_chunk_fn ||
+       if (!param->drv_read_chunk_fn ||
            !param->drv_write_chunk_fn ||
            !param->drv_erase_fn)
                return 0;
 
+       if (param->is_yaffs2 &&
+            (!param->drv_mark_bad_fn  || !param->drv_check_bad_fn))
+               return 0;
+
        /* Install the default tags marshalling functions if needed. */
        yaffs_tags_compat_install(dev);
        yaffs_tags_marshall_install(dev);
@@ -4924,8 +4928,7 @@ void yaffs_deinitialise(struct yaffs_dev *dev)
 
                dev->is_mounted = 0;
 
-               if (dev->param.drv_deinitialise_fn)
-                       dev->param.drv_deinitialise_fn(dev);
+               yaffs_deinit_nand(dev);
        }
 }
 
index 643e5750954784e1cfb2cdd2a5ac6f4268eb4c76..eab3e083dc685b9a25a83c37faf3f1e8dc160fe9 100644 (file)
@@ -607,7 +607,7 @@ struct yaffs_param {
        void (*sb_dirty_fn) (struct yaffs_dev *dev);
 
        /*  Callback to control garbage collection. */
-       unsigned (*gc_control) (struct yaffs_dev *dev);
+       unsigned (*gc_control_fn) (struct yaffs_dev *dev);
 
        /* Debug control flags. Don't use unless you know what you're doing */
        int use_header_file_size;       /* Flag to determine if we should use
index 8c522c84852a391e281df3b2815792de933f8721..c541e31b3061073590ae541a46b1819ff7a6b7b5 100644 (file)
@@ -29,8 +29,6 @@ struct yaffs_linux_context {
                                 * at compile time so we have to allocate it.
                                 */
        struct list_head search_contexts;
-       void (*put_super_fn) (struct super_block *sb);
-
        struct task_struct *readdir_process;
        unsigned mount_id;
 };
index 4c1993bb7d2eed23c54e38ded284c062f93dc29e..240abc4f5390ed2a79618d649289835c321e32fe 100644 (file)
@@ -109,3 +109,10 @@ int yaffs_init_nand(struct yaffs_dev *dev)
                return dev->param.drv_initialise_fn(dev);
        return YAFFS_OK;
 }
+
+int yaffs_deinit_nand(struct yaffs_dev *dev)
+{
+       if (dev->param.drv_deinitialise_fn)
+               return dev->param.drv_deinitialise_fn(dev);
+       return YAFFS_OK;
+}
index 71346627fc0b7db66a90b833231ce4d186f5b4d6..804e97ad66d0ca50385b730af435ea1d944d90eb 100644 (file)
@@ -34,5 +34,6 @@ int yaffs_query_init_block_state(struct yaffs_dev *dev,
 int yaffs_erase_block(struct yaffs_dev *dev, int flash_block);
 
 int yaffs_init_nand(struct yaffs_dev *dev);
+int yaffs_deinit_nand(struct yaffs_dev *dev);
 
 #endif
index 322f9819c3f47fef498b25e382aa8822ecea96a3..3cf6dde1717c394487c3780189da83801fddcb52 100644 (file)
@@ -2473,8 +2473,10 @@ struct mutex yaffs_context_lock;
 static void yaffs_put_super(struct super_block *sb)
 {
        struct yaffs_dev *dev = yaffs_super_to_dev(sb);
+       struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
 
-       yaffs_trace(YAFFS_TRACE_OS, "yaffs_put_super");
+       yaffs_trace(YAFFS_TRACE_OS | YAFFS_TRACE_ALWAYS,
+                       "yaffs_put_super");
 
        yaffs_trace(YAFFS_TRACE_OS | YAFFS_TRACE_BACKGROUND,
                "Shutting down yaffs background thread");
@@ -2486,9 +2488,6 @@ static void yaffs_put_super(struct super_block *sb)
 
        yaffs_flush_super(sb, 1);
 
-       if (yaffs_dev_to_lc(dev)->put_super_fn)
-               yaffs_dev_to_lc(dev)->put_super_fn(sb);
-
        yaffs_deinitialise(dev);
 
        yaffs_gross_unlock(dev);
@@ -2503,18 +2502,18 @@ static void yaffs_put_super(struct super_block *sb)
        }
 
        kfree(dev);
-}
-
-static void yaffs_mtd_put_super(struct super_block *sb)
-{
-       struct mtd_info *mtd = yaffs_dev_to_mtd(yaffs_super_to_dev(sb));
 
-       if (mtd->sync)
+       if (mtd && mtd->sync)
                mtd->sync(mtd);
 
-       put_mtd_device(mtd);
+       if(mtd)
+               put_mtd_device(mtd);
+
+       yaffs_trace(YAFFS_TRACE_OS | YAFFS_TRACE_ALWAYS,
+                       "yaffs_put_super done");
 }
 
+
 static void yaffs_touch_super(struct yaffs_dev *dev)
 {
        struct super_block *sb = yaffs_dev_to_lc(dev)->super;
@@ -2878,10 +2877,8 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
 
        yaffs_mtd_drv_install(dev);
 
-       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;
+       param->gc_control_fn = yaffs_gc_control_callback;
 
        yaffs_dev_to_lc(dev)->super = sb;
 
index 8d41f69a2b1f830028c060e08624a4e6dfcaa4ef..145517b69b165d4274037493075046c85c78ac58 100644 (file)
@@ -1912,6 +1912,7 @@ static void yaffs_fill_inode_from_obj(struct inode *inode,
 static void yaffs_put_super(struct super_block *sb)
 {
        struct yaffs_dev *dev = yaffs_super_to_dev(sb);
+       struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
 
        yaffs_trace(YAFFS_TRACE_OS, "yaffs_put_super");
 
@@ -1941,16 +1942,14 @@ static void yaffs_put_super(struct super_block *sb)
        }
 
        kfree(dev);
-}
 
-static void yaffs_mtd_put_super(struct super_block *sb)
-{
-       struct mtd_info *mtd = yaffs_dev_to_mtd(yaffs_super_to_dev(sb));
 
-       if (mtd->sync)
+
+       if (mtd && mtd->sync)
                mtd->sync(mtd);
 
-       put_mtd_device(mtd);
+       if (mtd)
+               put_mtd_device(mtd);
 }
 
 static const struct super_operations yaffs_super_ops = {
@@ -2213,7 +2212,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        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;
+       param->gc_control_fn = yaffs_gc_control_callback;
 
        yaffs_dev_to_lc(dev)->super = sb;