Seperate drivers and tags handlers into their own interface structures
[yaffs2.git] / yaffs_guts.c
index 0c33102b46bfc2e64cba900348f2582ccefd282e..ce5f2387ab0aad483d8c403c15e69dcc7be663b3 100644 (file)
@@ -609,10 +609,10 @@ static void yaffs_retire_block(struct yaffs_dev *dev, int flash_block)
                        memset(buffer, 0xff, dev->data_bytes_per_chunk);
                        memset(&tags, 0, sizeof(tags));
                        tags.seq_number = YAFFS_SEQUENCE_BAD_BLOCK;
-                       if (dev->param.write_chunk_tags_fn(dev, chunk_id -
-                                                          dev->chunk_offset,
-                                                          buffer,
-                                                          &tags) != YAFFS_OK)
+                       if (dev->th.write_chunk_tags_fn(dev, chunk_id -
+                                                       dev->chunk_offset,
+                                                       buffer,
+                                                       &tags) != YAFFS_OK)
                                yaffs_trace(YAFFS_TRACE_ALWAYS,
                                        "yaffs: Failed to write bad block marker to block %d",
                                        flash_block);
@@ -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)
@@ -4534,14 +4535,17 @@ YCHAR *yaffs_get_symlink_alias(struct yaffs_obj *obj)
 
 static int yaffs_check_dev_fns(struct yaffs_dev *dev)
 {
-       struct yaffs_param *param = &dev->param;
+       struct yaffs_driver *drv = &dev->drv;
+       struct yaffs_tags_handler *th = &dev->th;
 
        /* Common functions, gotta have */
-       if (!param->drv_initialise_fn ||
-           !param->drv_read_chunk_fn ||
-           !param->drv_write_chunk_fn ||
-           !param->drv_erase_fn ||
-           !param->drv_initialise_fn)
+       if (!drv->drv_read_chunk_fn ||
+           !drv->drv_write_chunk_fn ||
+           !drv->drv_erase_fn)
+               return 0;
+
+       if (dev->param.is_yaffs2 &&
+            (!drv->drv_mark_bad_fn  || !drv->drv_check_bad_fn))
                return 0;
 
        /* Install the default tags marshalling functions if needed. */
@@ -4549,10 +4553,10 @@ static int yaffs_check_dev_fns(struct yaffs_dev *dev)
        yaffs_tags_marshall_install(dev);
 
        /* Check we now have the marshalling functions required. */
-       if (!param->write_chunk_tags_fn ||
-           !param->read_chunk_tags_fn ||
-           !param->query_block_fn ||
-           !param->mark_bad_fn)
+       if (!th->write_chunk_tags_fn ||
+           !th->read_chunk_tags_fn ||
+           !th->query_block_fn ||
+           !th->mark_bad_fn)
                return 0;
 
        return 1;
@@ -4925,8 +4929,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);
        }
 }