Updated headers so they really are the same
[yaffs2.git] / yaffs_tagscompat.c
index 61880d5284fe3c598aa89a5b4757161b4b17fe55..d594d6193245ff7ae2f09c5ea063906c56bf7225 100644 (file)
@@ -1,16 +1,14 @@
 /*
- * YAFFS: Yet another FFS. A NAND-flash specific file system. 
- * yaffs_tagscompat.h: Tags compatability layer to use YAFFS1 formatted NAND.
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
  *
- * Copyright (C) 2002 Aleph One Ltd.
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
  *
  * Created by Charles Manning <charles@aleph1.co.uk>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
- *
- * $Id: yaffs_tagscompat.c,v 1.6 2005-08-11 02:33:03 marty Exp $
  */
 
 #include "yaffs_guts.h"
@@ -213,13 +211,13 @@ static int yaffs_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev,
                        if (eccResult1 > 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error fix performed on chunk %d:0"
+                                  ("**>>yaffs ecc error fix performed on chunk %d:0"
                                    TENDSTR), chunkInNAND));
                                dev->eccFixed++;
                        } else if (eccResult1 < 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error unfixed on chunk %d:0"
+                                  ("**>>yaffs ecc error unfixed on chunk %d:0"
                                    TENDSTR), chunkInNAND));
                                dev->eccUnfixed++;
                        }
@@ -227,13 +225,13 @@ static int yaffs_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev,
                        if (eccResult2 > 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error fix performed on chunk %d:1"
+                                  ("**>>yaffs ecc error fix performed on chunk %d:1"
                                    TENDSTR), chunkInNAND));
                                dev->eccFixed++;
                        } else if (eccResult2 < 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error unfixed on chunk %d:1"
+                                  ("**>>yaffs ecc error unfixed on chunk %d:1"
                                    TENDSTR), chunkInNAND));
                                dev->eccUnfixed++;
                        }
@@ -262,24 +260,24 @@ static int yaffs_ReadChunkFromNAND(struct yaffs_DeviceStruct *dev,
                        if (nspare.eccres1 > 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error fix performed on chunk %d:0"
+                                  ("**>>mtd ecc error fix performed on chunk %d:0"
                                    TENDSTR), chunkInNAND));
                        } else if (nspare.eccres1 < 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error unfixed on chunk %d:0"
+                                  ("**>>mtd ecc error unfixed on chunk %d:0"
                                    TENDSTR), chunkInNAND));
                        }
 
                        if (nspare.eccres2 > 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error fix performed on chunk %d:1"
+                                  ("**>>mtd ecc error fix performed on chunk %d:1"
                                    TENDSTR), chunkInNAND));
                        } else if (nspare.eccres2 < 0) {
                                T(YAFFS_TRACE_ERROR,
                                  (TSTR
-                                  ("**>>ecc error unfixed on chunk %d:1"
+                                  ("**>>mtd ecc error unfixed on chunk %d:1"
                                    TENDSTR), chunkInNAND));
                        }
 
@@ -455,20 +453,22 @@ int yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(yaffs_Device * dev,
                        int deleted =
                            (yaffs_CountBits(spare.pageStatus) < 7) ? 1 : 0;
 
-                       yaffs_GetTagsFromSpare(dev, &spare, &tags);
-
                        eTags->chunkDeleted = deleted;
-                       eTags->objectId = tags.objectId;
-                       eTags->chunkId = tags.chunkId;
-                       eTags->byteCount = tags.byteCount;
-                       eTags->serialNumber = tags.serialNumber;
                        eTags->eccResult = eccResult;
                        eTags->blockBad = 0;    /* We're reading it */
                        /* therefore it is not a bad block */
-
                        eTags->chunkUsed =
                            (memcmp(&spareFF, &spare, sizeof(spareFF)) !=
                             0) ? 1 : 0;
+
+                       if (eTags->chunkUsed) {
+                               yaffs_GetTagsFromSpare(dev, &spare, &tags);
+
+                               eTags->objectId = tags.objectId;
+                               eTags->chunkId = tags.chunkId;
+                               eTags->byteCount = tags.byteCount;
+                               eTags->serialNumber = tags.serialNumber;
+                       }
                }
 
                return YAFFS_OK;