Replace KERNEL_VERSION with MTD_VERSION so that builds which don't use
authorcolin <colin>
Wed, 12 Dec 2007 18:08:15 +0000 (18:08 +0000)
committercolin <colin>
Wed, 12 Dec 2007 18:08:15 +0000 (18:08 +0000)
a Linux Kernel still build correctly.
Set MTD_VERSION_CODE either from the kernel or by hand.

yaffs_mtdif.c
yaffs_mtdif1.c
yaffs_mtdif2.c
yportenv.h

index 6e2a9de22267318f34bb7c42deabdea3a3e8dca8..a1025a1177972b5c88372dc891380463d0377ef5 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 const char *yaffs_mtdif_c_version =
  */
 
 const char *yaffs_mtdif_c_version =
-    "$Id: yaffs_mtdif.c,v 1.19 2007-02-14 01:09:06 wookey Exp $";
+    "$Id: yaffs_mtdif.c,v 1.20 2007-12-12 18:08:15 colin Exp $";
 
 #include "yportenv.h"
 
 
 #include "yportenv.h"
 
@@ -24,7 +24,7 @@ const char *yaffs_mtdif_c_version =
 #include "linux/time.h"
 #include "linux/mtd/nand.h"
 
 #include "linux/time.h"
 #include "linux/mtd/nand.h"
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
+#if (MTD_VERSION_CODE < MTD_VERSION(2,6,18))
 static struct nand_oobinfo yaffs_oobinfo = {
        .useecc = 1,
        .eccbytes = 6,
 static struct nand_oobinfo yaffs_oobinfo = {
        .useecc = 1,
        .eccbytes = 6,
@@ -36,7 +36,7 @@ static struct nand_oobinfo yaffs_noeccinfo = {
 };
 #endif
 
 };
 #endif
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
 static inline void translate_spare2oob(const yaffs_Spare *spare, __u8 *oob)
 {
        oob[0] = spare->tagByte0;
 static inline void translate_spare2oob(const yaffs_Spare *spare, __u8 *oob)
 {
        oob[0] = spare->tagByte0;
@@ -75,14 +75,14 @@ int nandmtd_WriteChunkToNAND(yaffs_Device * dev, int chunkInNAND,
                             const __u8 * data, const yaffs_Spare * spare)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
                             const __u8 * data, const yaffs_Spare * spare)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        struct mtd_oob_ops ops;
 #endif
        size_t dummy;
        int retval = 0;
 
        loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
        struct mtd_oob_ops ops;
 #endif
        size_t dummy;
        int retval = 0;
 
        loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        __u8 spareAsBytes[8]; /* OOB */
 
        if (data && !spare)
        __u8 spareAsBytes[8]; /* OOB */
 
        if (data && !spare)
@@ -139,14 +139,14 @@ int nandmtd_ReadChunkFromNAND(yaffs_Device * dev, int chunkInNAND, __u8 * data,
                              yaffs_Spare * spare)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
                              yaffs_Spare * spare)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        struct mtd_oob_ops ops;
 #endif
        size_t dummy;
        int retval = 0;
 
        loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
        struct mtd_oob_ops ops;
 #endif
        size_t dummy;
        int retval = 0;
 
        loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        __u8 spareAsBytes[8]; /* OOB */
 
        if (data && !spare)
        __u8 spareAsBytes[8]; /* OOB */
 
        if (data && !spare)
index ad2932054659d1a9fd1b7fd4900097a642074ddd..99653e2bff4e2b442a289e0bd7b725ce883d60a7 100644 (file)
@@ -34,9 +34,9 @@
 #include "linux/mtd/mtd.h"
 
 /* Don't compile this module if we don't have MTD's mtd_oob_ops interface */
 #include "linux/mtd/mtd.h"
 
 /* Don't compile this module if we don't have MTD's mtd_oob_ops interface */
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
 
 
-const char *yaffs_mtdif1_c_version = "$Id: yaffs_mtdif1.c,v 1.5 2007-10-29 14:59:57 imcd Exp $";
+const char *yaffs_mtdif1_c_version = "$Id: yaffs_mtdif1.c,v 1.6 2007-12-12 18:08:15 colin Exp $";
 
 #ifndef CONFIG_YAFFS_9BYTE_TAGS
 # define YTAG1_SIZE 8
 
 #ifndef CONFIG_YAFFS_9BYTE_TAGS
 # define YTAG1_SIZE 8
@@ -189,7 +189,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
        ops.datbuf = data;
        ops.oobbuf = (__u8 *)&pt1;
 
        ops.datbuf = data;
        ops.oobbuf = (__u8 *)&pt1;
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+#if (MTD_VERSION_CODE < MTD_VERSION(2,6,20))
        /* In MTD 2.6.18 to 2.6.19 nand_base.c:nand_do_read_oob() has a bug;
         * help it out with ops.len = ops.ooblen when ops.datbuf == NULL.
         */
        /* In MTD 2.6.18 to 2.6.19 nand_base.c:nand_do_read_oob() has a bug;
         * help it out with ops.len = ops.ooblen when ops.datbuf == NULL.
         */
@@ -366,4 +366,4 @@ int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
        return YAFFS_OK;
 }
 
        return YAFFS_OK;
 }
 
-#endif /*KERNEL_VERSION*/
+#endif /*MTD_VERSION*/
index d927c76737ebc796c0bdaf2f50efa5515010bc54..47d74d33439714839500a37ddead8edb4ff1cee0 100644 (file)
@@ -14,7 +14,7 @@
 /* mtd interface for YAFFS2 */
 
 const char *yaffs_mtdif2_c_version =
 /* mtd interface for YAFFS2 */
 
 const char *yaffs_mtdif2_c_version =
-    "$Id: yaffs_mtdif2.c,v 1.17 2007-02-14 01:09:06 wookey Exp $";
+    "$Id: yaffs_mtdif2.c,v 1.18 2007-12-12 18:08:15 colin Exp $";
 
 #include "yportenv.h"
 
 
 #include "yportenv.h"
 
@@ -32,7 +32,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device * dev, int chunkInNAND,
                                      const yaffs_ExtendedTags * tags)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
                                      const yaffs_ExtendedTags * tags)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        struct mtd_oob_ops ops;
 #else
        size_t dummy;
        struct mtd_oob_ops ops;
 #else
        size_t dummy;
@@ -48,7 +48,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device * dev, int chunkInNAND,
           ("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p"
            TENDSTR), chunkInNAND, data, tags));
 
           ("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p"
            TENDSTR), chunkInNAND, data, tags));
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        if (tags)
                yaffs_PackTags2(&pt, tags);
        else
        if (tags)
                yaffs_PackTags2(&pt, tags);
        else
@@ -101,7 +101,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
                                       __u8 * data, yaffs_ExtendedTags * tags)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
                                       __u8 * data, yaffs_ExtendedTags * tags)
 {
        struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        struct mtd_oob_ops ops;
 #endif
        size_t dummy;
        struct mtd_oob_ops ops;
 #endif
        size_t dummy;
@@ -116,7 +116,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
           ("nandmtd2_ReadChunkWithTagsFromNAND chunk %d data %p tags %p"
            TENDSTR), chunkInNAND, data, tags));
 
           ("nandmtd2_ReadChunkWithTagsFromNAND chunk %d data %p tags %p"
            TENDSTR), chunkInNAND, data, tags));
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
+#if (MTD_VERSION_CODE > MTD_VERSION(2,6,17))
        if (data && !tags)
                retval = mtd->read(mtd, addr, dev->nDataBytesPerChunk,
                                &dummy, data);
        if (data && !tags)
                retval = mtd->read(mtd, addr, dev->nDataBytesPerChunk,
                                &dummy, data);
index 8b80c6d6889a6390eb41debb33345cce33b4b0b6..e1b148fdbb51a0edf2e8a27f1075024a2b2c2857 100644 (file)
 #ifndef __YPORTENV_H__
 #define __YPORTENV_H__
 
 #ifndef __YPORTENV_H__
 #define __YPORTENV_H__
 
+/*
+ * Define the MTD version in terms of Linux Kernel versions
+ * This allows yaffs to be used independantly of the kernel
+ * as well as with it.
+ */
+
+#define MTD_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+
 #if defined CONFIG_YAFFS_WINCE
 
 #include "ywinceenv.h"
 #if defined CONFIG_YAFFS_WINCE
 
 #include "ywinceenv.h"
 #include "moduleconfig.h"
 
 /* Linux kernel */
 #include "moduleconfig.h"
 
 /* Linux kernel */
+
 #include <linux/version.h>
 #include <linux/version.h>
+#define MTD_VERSION_CODE LINUX_VERSION_CODE
+
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
 #include <linux/config.h>
 #endif
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
 #include <linux/config.h>
 #endif
 
 #elif defined CONFIG_YAFFS_DIRECT
 
 
 #elif defined CONFIG_YAFFS_DIRECT
 
+#define MTD_VERSION_CODE MTD_VERSION(2,6,22)
+
 /* Direct interface */
 #include "ydirectenv.h"
 
 /* Direct interface */
 #include "ydirectenv.h"