From: Charles Manning Date: Thu, 21 Jun 2012 02:29:02 +0000 (+1200) Subject: Clean ups X-Git-Tag: aleph1-release~73^2~3 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=6c0b1f629b813db703ceac9e35822380d7f73f1f Clean ups Signed-off-by: Charles Manning --- diff --git a/yaffs_guts.c b/yaffs_guts.c index 66e8c5e..14ab472 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -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); } } diff --git a/yaffs_guts.h b/yaffs_guts.h index 643e575..eab3e08 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -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 diff --git a/yaffs_linux.h b/yaffs_linux.h index 8c522c8..c541e31 100644 --- a/yaffs_linux.h +++ b/yaffs_linux.h @@ -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; }; diff --git a/yaffs_nand.c b/yaffs_nand.c index 4c1993b..240abc4 100644 --- a/yaffs_nand.c +++ b/yaffs_nand.c @@ -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; +} diff --git a/yaffs_nand.h b/yaffs_nand.h index 7134662..804e97a 100644 --- a/yaffs_nand.h +++ b/yaffs_nand.h @@ -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 diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index 322f981..3cf6dde 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -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; diff --git a/yaffs_vfs_single.c b/yaffs_vfs_single.c index 8d41f69..145517b 100644 --- a/yaffs_vfs_single.c +++ b/yaffs_vfs_single.c @@ -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;