yaffs: More mainlining cleanup
[yaffs2.git] / yaffs_mtdif1_single.c
index 182870cb5ab63ca8526bf26184db2a58e8fd02a0..467a0319f74ff4d8fda305d159539e86d589ba14 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * YAFFS: Yet another FFS. A NAND-flash specific file system.
  *
- * Copyright (C) 2002-2010 Aleph One Ltd.
+ * Copyright (C) 2002-2011 Aleph One Ltd.
  *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
 #include "linux/types.h"
 #include "linux/mtd/mtd.h"
 
-#ifndef CONFIG_YAFFS_9BYTE_TAGS
-# define YTAG1_SIZE 8
-#else
-# define YTAG1_SIZE 9
-#endif
-
 /* Write a chunk (page) of data to NAND.
  *
  * Caller always provides ExtendedTags data which are converted to a more
@@ -86,25 +80,26 @@ int nandmtd1_write_chunk_tags(struct yaffs_dev *dev,
         * 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->is_deleted) {
-               memset(&pt1, 0xff, 8);
-               /* clear delete status bit to indicate deleted */
-               pt1.deleted = 0;
-       }
-#else
-       ((u8 *) &pt1)[8] = 0xff;
-       if (etags->is_deleted) {
-               memset(&pt1, 0xff, 8);
-               /* zero page_status byte to indicate deleted */
-               ((u8 *) &pt1)[8] = 0;
-       }
-#endif
+        
+       if(dev->param.tags_9bytes) {
+               ((u8 *) &pt1)[8] = 0xff;
+               if (etags->is_deleted) {
+                       memset(&pt1, 0xff, 8);
+                       /* zero page_status byte to indicate deleted */
+                       ((u8 *) &pt1)[8] = 0;
+                }
+        } else {
+               if (etags->is_deleted) {
+                       memset(&pt1, 0xff, 8);
+                       /* clear delete status bit to indicate deleted */
+                       pt1.deleted = 0;
+                }
+        }
 
        memset(&ops, 0, sizeof(ops));
        ops.mode = MTD_OOB_AUTO;
        ops.len = (data) ? chunk_bytes : 0;
-       ops.ooblen = YTAG1_SIZE;
+       ops.ooblen = dev->param.tags_9bytes ? 9 : 8;
        ops.datbuf = (u8 *) data;
        ops.oobbuf = (u8 *) &pt1;
 
@@ -157,7 +152,7 @@ int nandmtd1_read_chunk_tags(struct yaffs_dev *dev,
        memset(&ops, 0, sizeof(ops));
        ops.mode = MTD_OOB_AUTO;
        ops.len = (data) ? chunk_bytes : 0;
-       ops.ooblen = YTAG1_SIZE;
+       ops.ooblen =  dev->param.tags_9bytes ? 9 : 8;
        ops.datbuf = data;
        ops.oobbuf = (u8 *) &pt1;
 
@@ -231,7 +226,7 @@ int nandmtd1_read_chunk_tags(struct yaffs_dev *dev,
        /* Unpack the tags to extended form and set ECC result.
         * [set should_be_ff just to keep yaffs_unpack_tags1 happy]
         */
-       pt1.should_be_ff = 0xFFFFFFFF;
+       pt1.should_be_ff = 0xffffffff;
        yaffs_unpack_tags1(etags, &pt1);
        etags->ecc_result = eccres;
 
@@ -270,10 +265,10 @@ static int nandmtd1_test_prerequists(struct mtd_info *mtd)
        /* 2.6.21 has mtd->ecclayout->oobavail and mtd->oobavail */
        int oobavail = mtd->ecclayout->oobavail;
 
-       if (oobavail < YTAG1_SIZE) {
+       if (oobavail < (dev->param.tags_9bytes ? 9 : 8)) {
                yaffs_trace(YAFFS_TRACE_ERROR,
                        "mtd device has only %d bytes for tags, need %d",
-                       oobavail, YTAG1_SIZE);
+                       oobavail, (dev->param.tags_9bytes ? 9 : 8);
                return YAFFS_FAIL;
        }
        return YAFFS_OK;
@@ -283,7 +278,7 @@ static int nandmtd1_test_prerequists(struct mtd_info *mtd)
  *
  * 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_NEEDS_SCAN, the block is in use
  *  - YAFFS_BLOCK_STATE_EMPTY, the block is clean
  *
  * Always returns YAFFS_OK.
@@ -313,9 +308,9 @@ int nandmtd1_query_block(struct yaffs_dev *dev, int block_no,
                state = YAFFS_BLOCK_STATE_DEAD;
        } else if (etags.ecc_result != YAFFS_ECC_RESULT_NO_ERROR) {
                /* bad tags, need to look more closely */
-               state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
+               state = YAFFS_BLOCK_STATE_NEEDS_SCAN;
        } else if (etags.chunk_used) {
-               state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
+               state = YAFFS_BLOCK_STATE_NEEDS_SCAN;
                seqnum = etags.seq_number;
        } else {
                state = YAFFS_BLOCK_STATE_EMPTY;