From 443554816b244a3ca95741ef3380d3b045ee250c Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 12 Dec 2007 18:08:15 +0000 Subject: [PATCH] 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. --- yaffs_mtdif.c | 14 +++++++------- yaffs_mtdif1.c | 8 ++++---- yaffs_mtdif2.c | 10 +++++----- yportenv.h | 13 +++++++++++++ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/yaffs_mtdif.c b/yaffs_mtdif.c index 6e2a9de..a1025a1 100644 --- a/yaffs_mtdif.c +++ b/yaffs_mtdif.c @@ -12,7 +12,7 @@ */ 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" @@ -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_noeccinfo = { }; #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_Device * dev, int chunkInNAND, 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_Device * dev, int chunkInNAND, __u8 * data, 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) diff --git a/yaffs_mtdif1.c b/yaffs_mtdif1.c index ad29320..99653e2 100644 --- a/yaffs_mtdif1.c +++ b/yaffs_mtdif1.c @@ -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 */ -#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 @@ -189,7 +189,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev, 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_DeviceStruct *dev, int blockNo, return YAFFS_OK; } -#endif /*KERNEL_VERSION*/ +#endif /*MTD_VERSION*/ diff --git a/yaffs_mtdif2.c b/yaffs_mtdif2.c index d927c76..47d74d3 100644 --- a/yaffs_mtdif2.c +++ b/yaffs_mtdif2.c @@ -14,7 +14,7 @@ /* 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" @@ -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); -#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(yaffs_Device * dev, int chunkInNAND, ("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(yaffs_Device * dev, int chunkInNAND, __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(yaffs_Device * dev, int chunkInNAND, ("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); diff --git a/yportenv.h b/yportenv.h index 8b80c6d..e1b148f 100644 --- 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 +#define MTD_VERSION_CODE LINUX_VERSION_CODE + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) #include #endif @@ -90,6 +101,8 @@ #elif defined CONFIG_YAFFS_DIRECT +#define MTD_VERSION_CODE MTD_VERSION(2,6,22) + /* Direct interface */ #include "ydirectenv.h" -- 2.30.2