changeset 204:5ee93b08ed3a

Replace KERNEL_VERSION with MTD_VERSION so that builds which don't use a Linux Kernel still build correctly. Set MTD_VERSION_CODE either from the kernel or by hand.
author colin
date Wed, 12 Dec 2007 18:08:15 +0000
parents 88a05fb266f0
children f95fdc6123fb
files yaffs_mtdif.c yaffs_mtdif1.c yaffs_mtdif2.c yportenv.h
diffstat 4 files changed, 26 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/yaffs_mtdif.c
+++ b/yaffs_mtdif.c
@@ -24,7 +24,7 @@ const char *yaffs_mtdif_c_version =
 #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,
@@ -36,7 +36,7 @@ static struct nand_oobinfo yaffs_noeccin
 };
 #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;
@@ -75,14 +75,14 @@ int nandmtd_WriteChunkToNAND(yaffs_Devic
 			     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;
-#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)
@@ -139,14 +139,14 @@ int nandmtd_ReadChunkFromNAND(yaffs_Devi
 			      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;
-#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)
--- a/yaffs_mtdif1.c
+++ b/yaffs_mtdif1.c
@@ -34,7 +34,7 @@
 #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$";
 
@@ -189,7 +189,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(y
 	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.
 	 */
@@ -366,4 +366,4 @@ int nandmtd1_QueryNANDBlock(struct yaffs
 	return YAFFS_OK;
 }
 
-#endif /*KERNEL_VERSION*/
+#endif /*MTD_VERSION*/
--- a/yaffs_mtdif2.c
+++ b/yaffs_mtdif2.c
@@ -32,7 +32,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(ya
 				      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;
@@ -48,7 +48,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(ya
 	   ("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
@@ -101,7 +101,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y
 				       __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;
@@ -116,7 +116,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y
 	   ("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);
--- a/yportenv.h
+++ b/yportenv.h
@@ -17,6 +17,14 @@
 #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"
@@ -26,7 +34,10 @@
 #include "moduleconfig.h"
 
 /* Linux kernel */
+
 #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
@@ -90,6 +101,8 @@
 
 #elif defined CONFIG_YAFFS_DIRECT
 
+#define MTD_VERSION_CODE MTD_VERSION(2,6,22)
+
 /* Direct interface */
 #include "ydirectenv.h"