Mercurial > yaffs-ecoscentric-gpl
comparison yaffs_mtdif1.c @ 409:b5309c9b6d7f
yaffs Some cleanups.
Update copyright messages.
Clean up tracing to use TSTR and KERN_DEBUG.
Remove cvs $Id.
Change /proc/yaffs_debug to /proc/yaffs_stats.
... and a few other clean ups.
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
| author | Charles Manning <cdhmanning@gmail.com> |
|---|---|
| date | Tue, 20 Apr 2010 17:12:46 +1200 |
| parents | 7ee0cc4ba753 |
| children |
comparison
equal
deleted
inserted
replaced
| 408:fc1d08b30cc0 | 409:b5309c9b6d7f |
|---|---|
| 1 /* | 1 /* |
| 2 * YAFFS: Yet another FFS. A NAND-flash specific file system. | 2 * YAFFS: Yet another FFS. A NAND-flash specific file system. |
| 3 * yaffs_mtdif1.c NAND mtd interface functions for small-page NAND. | 3 * yaffs_mtdif1.c NAND mtd interface functions for small-page NAND. |
| 4 * | 4 * |
| 5 * Copyright (C) 2002 Aleph One Ltd. | 5 * Copyright (C) 2002-2010 Aleph One Ltd. |
| 6 * for Toby Churchill Ltd and Brightstar Engineering | 6 * for Toby Churchill Ltd and Brightstar Engineering |
| 7 * | 7 * |
| 8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License version 2 as | 9 * it under the terms of the GNU General Public License version 2 as |
| 10 * published by the Free Software Foundation. | 10 * published by the Free Software Foundation. |
| 35 #include "linux/types.h" | 35 #include "linux/types.h" |
| 36 #include "linux/mtd/mtd.h" | 36 #include "linux/mtd/mtd.h" |
| 37 | 37 |
| 38 /* Don't compile this module if we don't have MTD's mtd_oob_ops interface */ | 38 /* Don't compile this module if we don't have MTD's mtd_oob_ops interface */ |
| 39 #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17)) | 39 #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17)) |
| 40 | |
| 41 const char *yaffs_mtdif1_c_version = "$Id: yaffs_mtdif1.c,v 1.13 2010-02-18 01:18:04 charles Exp $"; | |
| 42 | 40 |
| 43 #ifndef CONFIG_YAFFS_9BYTE_TAGS | 41 #ifndef CONFIG_YAFFS_9BYTE_TAGS |
| 44 # define YTAG1_SIZE 8 | 42 # define YTAG1_SIZE 8 |
| 45 #else | 43 #else |
| 46 # define YTAG1_SIZE 9 | 44 # define YTAG1_SIZE 9 |
| 135 ops.datbuf = (__u8 *)data; | 133 ops.datbuf = (__u8 *)data; |
| 136 ops.oobbuf = (__u8 *)&pt1; | 134 ops.oobbuf = (__u8 *)&pt1; |
| 137 | 135 |
| 138 retval = mtd->write_oob(mtd, addr, &ops); | 136 retval = mtd->write_oob(mtd, addr, &ops); |
| 139 if (retval) { | 137 if (retval) { |
| 140 yaffs_trace(YAFFS_TRACE_MTD, | 138 T(YAFFS_TRACE_MTD, |
| 141 "write_oob failed, chunk %d, mtd error %d\n", | 139 (TSTR("write_oob failed, chunk %d, mtd error %d"TENDSTR), |
| 142 chunkInNAND, retval); | 140 chunkInNAND, retval)); |
| 143 } | 141 } |
| 144 return retval ? YAFFS_FAIL : YAFFS_OK; | 142 return retval ? YAFFS_FAIL : YAFFS_OK; |
| 145 } | 143 } |
| 146 | 144 |
| 147 /* Return with empty ExtendedTags but add eccResult. | 145 /* Return with empty ExtendedTags but add eccResult. |
| 196 /* Read page and oob using MTD. | 194 /* Read page and oob using MTD. |
| 197 * Check status and determine ECC result. | 195 * Check status and determine ECC result. |
| 198 */ | 196 */ |
| 199 retval = mtd->read_oob(mtd, addr, &ops); | 197 retval = mtd->read_oob(mtd, addr, &ops); |
| 200 if (retval) { | 198 if (retval) { |
| 201 yaffs_trace(YAFFS_TRACE_MTD, | 199 T(YAFFS_TRACE_MTD, |
| 202 "read_oob failed, chunk %d, mtd error %d\n", | 200 (TSTR("read_oob failed, chunk %d, mtd error %d"TENDSTR), |
| 203 chunkInNAND, retval); | 201 chunkInNAND, retval)); |
| 204 } | 202 } |
| 205 | 203 |
| 206 switch (retval) { | 204 switch (retval) { |
| 207 case 0: | 205 case 0: |
| 208 /* no error */ | 206 /* no error */ |
| 284 { | 282 { |
| 285 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; | 283 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; |
| 286 int blocksize = dev->param.nChunksPerBlock * dev->nDataBytesPerChunk; | 284 int blocksize = dev->param.nChunksPerBlock * dev->nDataBytesPerChunk; |
| 287 int retval; | 285 int retval; |
| 288 | 286 |
| 289 yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, "marking block %d bad\n", blockNo); | 287 T(YAFFS_TRACE_BAD_BLOCKS,(TSTR("marking block %d bad"TENDSTR), blockNo)); |
| 290 | 288 |
| 291 retval = mtd->block_markbad(mtd, (loff_t)blocksize * blockNo); | 289 retval = mtd->block_markbad(mtd, (loff_t)blocksize * blockNo); |
| 292 return (retval) ? YAFFS_FAIL : YAFFS_OK; | 290 return (retval) ? YAFFS_FAIL : YAFFS_OK; |
| 293 } | 291 } |
| 294 | 292 |
| 301 /* 2.6.18 has mtd->ecclayout->oobavail */ | 299 /* 2.6.18 has mtd->ecclayout->oobavail */ |
| 302 /* 2.6.21 has mtd->ecclayout->oobavail and mtd->oobavail */ | 300 /* 2.6.21 has mtd->ecclayout->oobavail and mtd->oobavail */ |
| 303 int oobavail = mtd->ecclayout->oobavail; | 301 int oobavail = mtd->ecclayout->oobavail; |
| 304 | 302 |
| 305 if (oobavail < YTAG1_SIZE) { | 303 if (oobavail < YTAG1_SIZE) { |
| 306 yaffs_trace(YAFFS_TRACE_ERROR, | 304 T(YAFFS_TRACE_ERROR, |
| 307 "mtd device has only %d bytes for tags, need %d\n", | 305 (TSTR("mtd device has only %d bytes for tags, need %d"TENDSTR), |
| 308 oobavail, YTAG1_SIZE); | 306 oobavail, YTAG1_SIZE)); |
| 309 return YAFFS_FAIL; | 307 return YAFFS_FAIL; |
| 310 } | 308 } |
| 311 return YAFFS_OK; | 309 return YAFFS_OK; |
| 312 } | 310 } |
| 313 | 311 |
| 338 return YAFFS_FAIL; | 336 return YAFFS_FAIL; |
| 339 | 337 |
| 340 retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags); | 338 retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags); |
| 341 etags.blockBad = (mtd->block_isbad)(mtd, addr); | 339 etags.blockBad = (mtd->block_isbad)(mtd, addr); |
| 342 if (etags.blockBad) { | 340 if (etags.blockBad) { |
| 343 yaffs_trace(YAFFS_TRACE_BAD_BLOCKS, | 341 T(YAFFS_TRACE_BAD_BLOCKS, |
| 344 "block %d is marked bad\n", blockNo); | 342 (TSTR("block %d is marked bad"TENDSTR), blockNo)); |
| 345 state = YAFFS_BLOCK_STATE_DEAD; | 343 state = YAFFS_BLOCK_STATE_DEAD; |
| 346 } else if (etags.eccResult != YAFFS_ECC_RESULT_NO_ERROR) { | 344 } else if (etags.eccResult != YAFFS_ECC_RESULT_NO_ERROR) { |
| 347 /* bad tags, need to look more closely */ | 345 /* bad tags, need to look more closely */ |
| 348 state = YAFFS_BLOCK_STATE_NEEDS_SCANNING; | 346 state = YAFFS_BLOCK_STATE_NEEDS_SCANNING; |
| 349 } else if (etags.chunkUsed) { | 347 } else if (etags.chunkUsed) { |
