projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaffs working on the timothy_tests. just need to save the current state of the program.
[yaffs2.git]
/
yaffs_mtdif1.c
diff --git
a/yaffs_mtdif1.c
b/yaffs_mtdif1.c
index b14a2549ca6c51b1f7cd3831002b80598837f320..ca7b0a37896d8a371f864fe1e2510f506746f8a7 100644
(file)
--- a/
yaffs_mtdif1.c
+++ b/
yaffs_mtdif1.c
@@
-18,16
+18,16
@@
*
* These functions are invoked via function pointers in yaffs_nand.c.
* This replaces functionality provided by functions in yaffs_mtdif.c
*
* These functions are invoked via function pointers in yaffs_nand.c.
* This replaces functionality provided by functions in yaffs_mtdif.c
- * and the yaffs_
Tags
Compatability functions in yaffs_tagscompat.c that are
+ * and the yaffs_
tags_t
Compatability functions in yaffs_tagscompat.c that are
* called in yaffs_mtdif.c when the function pointers are NULL.
* called in yaffs_mtdif.c when the function pointers are NULL.
- * We assume the MTD layer is performing ECC (use
NANDECC
is true).
+ * We assume the MTD layer is performing ECC (use
_nand_ecc
is true).
*/
#include "yportenv.h"
#include "yaffs_trace.h"
#include "yaffs_guts.h"
#include "yaffs_packedtags1.h"
*/
#include "yportenv.h"
#include "yaffs_trace.h"
#include "yaffs_guts.h"
#include "yaffs_packedtags1.h"
-#include "yaffs_tagscompat.h" /* for yaffs_
CalcTagsECC
*/
+#include "yaffs_tagscompat.h" /* for yaffs_
calc_tags_ecc
*/
#include "yaffs_linux.h"
#include "linux/kernel.h"
#include "yaffs_linux.h"
#include "linux/kernel.h"
@@
-51,12
+51,12
@@
* adjust 'oobfree' to match your existing Yaffs data.
*
* This nand_ecclayout scatters/gathers to/from the old-yaffs layout with the
* adjust 'oobfree' to match your existing Yaffs data.
*
* This nand_ecclayout scatters/gathers to/from the old-yaffs layout with the
- * page
S
tatus byte (at NAND spare offset 4) scattered/gathered from/to
+ * page
_s
tatus byte (at NAND spare offset 4) scattered/gathered from/to
* the 9th byte.
*
* Old-style on-NAND format: T0,T1,T2,T3,P,B,T4,T5,E0,E1,E2,T6,T7,E3,E4,E5
* the 9th byte.
*
* Old-style on-NAND format: T0,T1,T2,T3,P,B,T4,T5,E0,E1,E2,T6,T7,E3,E4,E5
- * We have/need PackedTags1 plus page
S
tatus: T0,T1,T2,T3,T4,T5,T6,T7,P
- * where Tn are the tag bytes, En are MTD's ECC bytes, P is the page
S
tatus
+ * We have/need PackedTags1 plus page
_s
tatus: T0,T1,T2,T3,T4,T5,T6,T7,P
+ * where Tn are the tag bytes, En are MTD's ECC bytes, P is the page
_s
tatus
* byte and B is the small-page bad-block indicator byte.
*/
static struct nand_ecclayout nand_oob_16 = {
* byte and B is the small-page bad-block indicator byte.
*/
static struct nand_ecclayout nand_oob_16 = {
@@
-88,40
+88,40
@@
static struct nand_ecclayout nand_oob_16 = {
* Any underlying MTD error results in YAFFS_FAIL.
* Returns YAFFS_OK or YAFFS_FAIL.
*/
* Any underlying MTD error results in YAFFS_FAIL.
* Returns YAFFS_OK or YAFFS_FAIL.
*/
-int nandmtd1_WriteChunkWithTagsToNAND(yaffs_
Device
*dev,
- int
chunkInNAND, const __u8 *data, const yaffs_ExtendedT
ags *etags)
+int nandmtd1_WriteChunkWithTagsToNAND(yaffs_
dev_t
*dev,
+ int
nand_chunk, const __u8 *data, const yaffs_ext_t
ags *etags)
{
{
- struct mtd_info *mtd = yaffs_
DeviceToM
td(dev);
- int chunkBytes = dev->
nDataBytesPerC
hunk;
- loff_t addr = ((loff_t)
chunkInNAND
) * chunkBytes;
+ struct mtd_info *mtd = yaffs_
dev_to_m
td(dev);
+ int chunkBytes = dev->
data_bytes_per_c
hunk;
+ loff_t addr = ((loff_t)
nand_chunk
) * chunkBytes;
struct mtd_oob_ops ops;
yaffs_PackedTags1 pt1;
int retval;
struct mtd_oob_ops ops;
yaffs_PackedTags1 pt1;
int retval;
- /* we assume that PackedTags1 and yaffs_
Tags
are compatible */
+ /* we assume that PackedTags1 and yaffs_
tags_t
are compatible */
compile_time_assertion(sizeof(yaffs_PackedTags1) == 12);
compile_time_assertion(sizeof(yaffs_PackedTags1) == 12);
- compile_time_assertion(sizeof(yaffs_
Tags
) == 8);
+ compile_time_assertion(sizeof(yaffs_
tags_t
) == 8);
yaffs_PackTags1(&pt1, etags);
yaffs_PackTags1(&pt1, etags);
- yaffs_
CalcTagsECC((yaffs_Tags
*)&pt1);
+ yaffs_
calc_tags_ecc((yaffs_tags_t
*)&pt1);
/* When deleting a chunk, the upper layer provides only skeletal
/* When deleting a chunk, the upper layer provides only skeletal
- * etags, one with
chunkD
eleted set. However, we need to update the
+ * etags, one with
is_d
eleted set. However, we need to update the
* tags, not erase them completely. So we use the NAND write property
* that only zeroed-bits stick and set tag bytes to all-ones and
* zero just the (not) deleted bit.
*/
#ifndef CONFIG_YAFFS_9BYTE_TAGS
* tags, not erase them completely. So we use the NAND write property
* that only zeroed-bits stick and set tag bytes to all-ones and
* zero just the (not) deleted bit.
*/
#ifndef CONFIG_YAFFS_9BYTE_TAGS
- if (etags->
chunkD
eleted) {
+ if (etags->
is_d
eleted) {
memset(&pt1, 0xff, 8);
/* clear delete status bit to indicate deleted */
pt1.deleted = 0;
}
#else
((__u8 *)&pt1)[8] = 0xff;
memset(&pt1, 0xff, 8);
/* clear delete status bit to indicate deleted */
pt1.deleted = 0;
}
#else
((__u8 *)&pt1)[8] = 0xff;
- if (etags->
chunkD
eleted) {
+ if (etags->
is_d
eleted) {
memset(&pt1, 0xff, 8);
memset(&pt1, 0xff, 8);
- /* zero page
S
tatus byte to indicate deleted */
+ /* zero page
_s
tatus byte to indicate deleted */
((__u8 *)&pt1)[8] = 0;
}
#endif
((__u8 *)&pt1)[8] = 0;
}
#endif
@@
-137,18
+137,18
@@
int nandmtd1_WriteChunkWithTagsToNAND(yaffs_Device *dev,
if (retval) {
T(YAFFS_TRACE_MTD,
(TSTR("write_oob failed, chunk %d, mtd error %d"TENDSTR),
if (retval) {
T(YAFFS_TRACE_MTD,
(TSTR("write_oob failed, chunk %d, mtd error %d"TENDSTR),
-
chunkInNAND
, retval));
+
nand_chunk
, retval));
}
return retval ? YAFFS_FAIL : YAFFS_OK;
}
}
return retval ? YAFFS_FAIL : YAFFS_OK;
}
-/* Return with empty ExtendedTags but add ecc
R
esult.
+/* Return with empty ExtendedTags but add ecc
_r
esult.
*/
*/
-static int rettags(yaffs_
ExtendedTags *etags, int eccR
esult, int retval)
+static int rettags(yaffs_
ext_tags *etags, int ecc_r
esult, int retval)
{
if (etags) {
memset(etags, 0, sizeof(*etags));
{
if (etags) {
memset(etags, 0, sizeof(*etags));
- etags->ecc
Result = eccR
esult;
+ etags->ecc
_result = ecc_r
esult;
}
return retval;
}
}
return retval;
}
@@
-156,22
+156,22
@@
static int rettags(yaffs_ExtendedTags *etags, int eccResult, int retval)
/* Read a chunk (page) from NAND.
*
* Caller expects ExtendedTags data to be usable even on error; that is,
/* Read a chunk (page) from NAND.
*
* Caller expects ExtendedTags data to be usable even on error; that is,
- * all members except ecc
Result and blockB
ad are zeroed.
+ * all members except ecc
_result and block_b
ad are zeroed.
*
* - Check ECC results for data (if applicable)
* - Check for blank/erased block (return empty ExtendedTags if blank)
* - Check the PackedTags1 mini-ECC (correct if necessary/possible)
* - Convert PackedTags1 to ExtendedTags
*
* - Check ECC results for data (if applicable)
* - Check for blank/erased block (return empty ExtendedTags if blank)
* - Check the PackedTags1 mini-ECC (correct if necessary/possible)
* - Convert PackedTags1 to ExtendedTags
- * - Update ecc
Result and blockB
ad members to refect state.
+ * - Update ecc
_result and block_b
ad members to refect state.
*
* Returns YAFFS_OK or YAFFS_FAIL.
*/
*
* Returns YAFFS_OK or YAFFS_FAIL.
*/
-int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_
Device
*dev,
- int
chunkInNAND, __u8 *data, yaffs_ExtendedT
ags *etags)
+int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_
dev_t
*dev,
+ int
nand_chunk, __u8 *data, yaffs_ext_t
ags *etags)
{
{
- struct mtd_info *mtd = yaffs_
DeviceToM
td(dev);
- int chunkBytes = dev->
nDataBytesPerC
hunk;
- loff_t addr = ((loff_t)
chunkInNAND
) * chunkBytes;
+ struct mtd_info *mtd = yaffs_
dev_to_m
td(dev);
+ int chunkBytes = dev->
data_bytes_per_c
hunk;
+ loff_t addr = ((loff_t)
nand_chunk
) * chunkBytes;
int eccres = YAFFS_ECC_RESULT_NO_ERROR;
struct mtd_oob_ops ops;
yaffs_PackedTags1 pt1;
int eccres = YAFFS_ECC_RESULT_NO_ERROR;
struct mtd_oob_ops ops;
yaffs_PackedTags1 pt1;
@@
-198,7
+198,7
@@
int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
if (retval) {
T(YAFFS_TRACE_MTD,
(TSTR("read_oob failed, chunk %d, mtd error %d"TENDSTR),
if (retval) {
T(YAFFS_TRACE_MTD,
(TSTR("read_oob failed, chunk %d, mtd error %d"TENDSTR),
-
chunkInNAND
, retval));
+
nand_chunk
, retval));
}
switch (retval) {
}
switch (retval) {
@@
-209,23
+209,23
@@
int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
case -EUCLEAN:
/* MTD's ECC fixed the data */
eccres = YAFFS_ECC_RESULT_FIXED;
case -EUCLEAN:
/* MTD's ECC fixed the data */
eccres = YAFFS_ECC_RESULT_FIXED;
- dev->
eccF
ixed++;
+ dev->
n_ecc_f
ixed++;
break;
case -EBADMSG:
/* MTD's ECC could not fix the data */
break;
case -EBADMSG:
/* MTD's ECC could not fix the data */
- dev->
eccU
nfixed++;
+ dev->
n_ecc_u
nfixed++;
/* fall into... */
default:
rettags(etags, YAFFS_ECC_RESULT_UNFIXED, 0);
/* fall into... */
default:
rettags(etags, YAFFS_ECC_RESULT_UNFIXED, 0);
- etags->block
B
ad = (mtd->block_isbad)(mtd, addr);
+ etags->block
_b
ad = (mtd->block_isbad)(mtd, addr);
return YAFFS_FAIL;
}
/* Check for a blank/erased chunk.
*/
return YAFFS_FAIL;
}
/* Check for a blank/erased chunk.
*/
- if (yaffs_
CheckFF
((__u8 *)&pt1, 8)) {
- /* when blank, upper layers want ecc
R
esult to be <= NO_ERROR */
+ if (yaffs_
check_ff
((__u8 *)&pt1, 8)) {
+ /* when blank, upper layers want ecc
_r
esult to be <= NO_ERROR */
return rettags(etags, YAFFS_ECC_RESULT_NO_ERROR, YAFFS_OK);
}
return rettags(etags, YAFFS_ECC_RESULT_NO_ERROR, YAFFS_OK);
}
@@
-237,37
+237,37
@@
int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
deleted = !pt1.deleted;
pt1.deleted = 1;
#else
deleted = !pt1.deleted;
pt1.deleted = 1;
#else
- deleted = (yaffs_
CountB
its(((__u8 *)&pt1)[8]) < 7);
+ deleted = (yaffs_
count_b
its(((__u8 *)&pt1)[8]) < 7);
#endif
/* Check the packed tags mini-ECC and correct if necessary/possible.
*/
#endif
/* Check the packed tags mini-ECC and correct if necessary/possible.
*/
- retval = yaffs_
CheckECCOnTags((yaffs_Tags
*)&pt1);
+ retval = yaffs_
check_tags_ecc((yaffs_tags_t
*)&pt1);
switch (retval) {
case 0:
/* no tags error, use MTD result */
break;
case 1:
/* recovered tags-ECC error */
switch (retval) {
case 0:
/* no tags error, use MTD result */
break;
case 1:
/* recovered tags-ECC error */
- dev->
tagsEccF
ixed++;
+ dev->
n_tags_ecc_f
ixed++;
if (eccres == YAFFS_ECC_RESULT_NO_ERROR)
eccres = YAFFS_ECC_RESULT_FIXED;
break;
default:
/* unrecovered tags-ECC error */
if (eccres == YAFFS_ECC_RESULT_NO_ERROR)
eccres = YAFFS_ECC_RESULT_FIXED;
break;
default:
/* unrecovered tags-ECC error */
- dev->
tagsEccU
nfixed++;
+ dev->
n_tags_ecc_u
nfixed++;
return rettags(etags, YAFFS_ECC_RESULT_UNFIXED, YAFFS_FAIL);
}
/* Unpack the tags to extended form and set ECC result.
return rettags(etags, YAFFS_ECC_RESULT_UNFIXED, YAFFS_FAIL);
}
/* Unpack the tags to extended form and set ECC result.
- * [set shouldBeFF just to keep yaffs_
UnpackT
ags1 happy]
+ * [set shouldBeFF just to keep yaffs_
unpack_t
ags1 happy]
*/
pt1.shouldBeFF = 0xFFFFFFFF;
*/
pt1.shouldBeFF = 0xFFFFFFFF;
- yaffs_
UnpackT
ags1(etags, &pt1);
- etags->ecc
R
esult = eccres;
+ yaffs_
unpack_t
ags1(etags, &pt1);
+ etags->ecc
_r
esult = eccres;
/* Set deleted state */
/* Set deleted state */
- etags->
chunkD
eleted = deleted;
+ etags->
is_d
eleted = deleted;
return YAFFS_OK;
}
return YAFFS_OK;
}
@@
-278,15
+278,15
@@
int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
*
* Returns YAFFS_OK or YAFFS_FAIL.
*/
*
* Returns YAFFS_OK or YAFFS_FAIL.
*/
-int nandmtd1_MarkNANDBlockBad(struct yaffs_
DeviceStruct *dev, int blockN
o)
+int nandmtd1_MarkNANDBlockBad(struct yaffs_
dev_s *dev, int block_n
o)
{
{
- struct mtd_info *mtd = yaffs_
DeviceToM
td(dev);
- int blocksize = dev->param.
nChunksPerBlock * dev->nDataBytesPerC
hunk;
+ struct mtd_info *mtd = yaffs_
dev_to_m
td(dev);
+ int blocksize = dev->param.
chunks_per_block * dev->data_bytes_per_c
hunk;
int retval;
int retval;
- T(YAFFS_TRACE_BAD_BLOCKS,(TSTR("marking block %d bad"TENDSTR), block
N
o));
+ T(YAFFS_TRACE_BAD_BLOCKS,(TSTR("marking block %d bad"TENDSTR), block
_n
o));
- retval = mtd->block_markbad(mtd, (loff_t)blocksize * block
N
o);
+ retval = mtd->block_markbad(mtd, (loff_t)blocksize * block
_n
o);
return (retval) ? YAFFS_FAIL : YAFFS_OK;
}
return (retval) ? YAFFS_FAIL : YAFFS_OK;
}
@@
-318,13
+318,13
@@
static int nandmtd1_TestPrerequists(struct mtd_info *mtd)
*
* Always returns YAFFS_OK.
*/
*
* Always returns YAFFS_OK.
*/
-int nandmtd1_QueryNANDBlock(struct yaffs_
DeviceStruct *dev, int blockN
o,
- yaffs_
BlockState
*pState, __u32 *pSequenceNumber)
+int nandmtd1_QueryNANDBlock(struct yaffs_
dev_s *dev, int block_n
o,
+ yaffs_
block_state_t
*pState, __u32 *pSequenceNumber)
{
{
- struct mtd_info *mtd = yaffs_
DeviceToM
td(dev);
- int chunkNo = block
No * dev->param.nChunksPerB
lock;
- loff_t addr = (loff_t)chunkNo * dev->
nDataBytesPerC
hunk;
- yaffs_
ExtendedT
ags etags;
+ struct mtd_info *mtd = yaffs_
dev_to_m
td(dev);
+ int chunkNo = block
_no * dev->param.chunks_per_b
lock;
+ loff_t addr = (loff_t)chunkNo * dev->
data_bytes_per_c
hunk;
+ yaffs_
ext_t
ags etags;
int state = YAFFS_BLOCK_STATE_DEAD;
int seqnum = 0;
int retval;
int state = YAFFS_BLOCK_STATE_DEAD;
int seqnum = 0;
int retval;
@@
-336,17
+336,17
@@
int nandmtd1_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo,
return YAFFS_FAIL;
retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags);
return YAFFS_FAIL;
retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags);
- etags.block
B
ad = (mtd->block_isbad)(mtd, addr);
- if (etags.block
B
ad) {
+ etags.block
_b
ad = (mtd->block_isbad)(mtd, addr);
+ if (etags.block
_b
ad) {
T(YAFFS_TRACE_BAD_BLOCKS,
T(YAFFS_TRACE_BAD_BLOCKS,
- (TSTR("block %d is marked bad"TENDSTR), block
N
o));
+ (TSTR("block %d is marked bad"TENDSTR), block
_n
o));
state = YAFFS_BLOCK_STATE_DEAD;
state = YAFFS_BLOCK_STATE_DEAD;
- } else if (etags.ecc
R
esult != YAFFS_ECC_RESULT_NO_ERROR) {
+ } else if (etags.ecc
_r
esult != YAFFS_ECC_RESULT_NO_ERROR) {
/* bad tags, need to look more closely */
state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
/* bad tags, need to look more closely */
state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
- } else if (etags.chunk
U
sed) {
+ } else if (etags.chunk
_u
sed) {
state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
- seqnum = etags.seq
uenceN
umber;
+ seqnum = etags.seq
_n
umber;
} else {
state = YAFFS_BLOCK_STATE_EMPTY;
}
} else {
state = YAFFS_BLOCK_STATE_EMPTY;
}