X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_mtdif1.c;h=2aad44ef1541f35c6defcbf7f4050c54efcfaa9d;hp=7493f9b2d62c18167e992d497314181b14189a46;hb=d8ff7698762028c417be5dbc102fe882be0f99c5;hpb=2f1bf981f055716660bbd10cfdd391b69f074f5e diff --git a/yaffs_mtdif1.c b/yaffs_mtdif1.c index 7493f9b..2aad44e 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.2 2007-07-23 19:14:04 imcd Exp $"; +const char *yaffs_mtdif1_c_version = "$Id: yaffs_mtdif1.c,v 1.8 2008-07-23 03:35:12 charles 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. */ @@ -288,14 +288,14 @@ int nandmtd1_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo) int blocksize = dev->nChunksPerBlock * dev->nDataBytesPerChunk; int retval; - yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, "marking block %d bad", blockNo); + yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, "marking block %d bad\n", blockNo); retval = mtd->block_markbad(mtd, (loff_t)blocksize * blockNo); return (retval) ? YAFFS_FAIL : YAFFS_OK; } /* Check any MTD prerequists. - * + * * Returns YAFFS_OK or YAFFS_FAIL. */ static int nandmtd1_TestPrerequists(struct mtd_info * mtd) @@ -323,10 +323,11 @@ static int nandmtd1_TestPrerequists(struct mtd_info * mtd) * Always returns YAFFS_OK. */ int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, - yaffs_BlockState * pState, int *pSequenceNumber) + yaffs_BlockState * pState, __u32 *pSequenceNumber) { struct mtd_info * mtd = dev->genericDevice; int chunkNo = blockNo * dev->nChunksPerBlock; + loff_t addr = (loff_t)chunkNo * dev->nDataBytesPerChunk; yaffs_ExtendedTags etags; int state = YAFFS_BLOCK_STATE_DEAD; int seqnum = 0; @@ -340,11 +341,16 @@ int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, } retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags); + etags.blockBad = (mtd->block_isbad)(mtd, addr); if (etags.blockBad) { yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, - "block %d is marked bad", blockNo); + "block %d is marked bad\n", blockNo); state = YAFFS_BLOCK_STATE_DEAD; } + else if (etags.eccResult != YAFFS_ECC_RESULT_NO_ERROR) { + /* bad tags, need to look more closely */ + state = YAFFS_BLOCK_STATE_NEEDS_SCANNING; + } else if (etags.chunkUsed) { state = YAFFS_BLOCK_STATE_NEEDS_SCANNING; seqnum = etags.sequenceNumber; @@ -360,4 +366,4 @@ int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, return YAFFS_OK; } -#endif /*KERNEL_VERSION*/ +#endif /*MTD_VERSION*/