projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'timothy'
[yaffs2.git]
/
yaffs_mtdif1.c
diff --git
a/yaffs_mtdif1.c
b/yaffs_mtdif1.c
index 70876bc34bb3283226b314ef50510871237ec791..b6d6713d9ededa5ca6942034aeed17f2b6401e14 100644
(file)
--- a/
yaffs_mtdif1.c
+++ b/
yaffs_mtdif1.c
@@
-1,10
+1,11
@@
/*
* YAFFS: Yet another FFS. A NAND-flash specific file system.
/*
* YAFFS: Yet another FFS. A NAND-flash specific file system.
- * yaffs_mtdif1.c NAND mtd interface functions for small-page NAND.
*
* Copyright (C) 2002-2010 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering
*
*
* Copyright (C) 2002-2010 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering
*
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
@@
-18,9
+19,9
@@
*
* 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 "yportenv.h"
@@
-51,12
+52,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
+89,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_dev_to_mtd(dev);
{
struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
- int chunkBytes = dev->
nDataBytesPerC
hunk;
- loff_t addr = ((loff_t)
chunkInNAND
) * chunkBytes;
+ 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_calc_tags_ecc((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
+138,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
+157,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_dev_to_mtd(dev);
{
struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
- int chunkBytes = dev->
nDataBytesPerC
hunk;
- loff_t addr = ((loff_t)
chunkInNAND
) * chunkBytes;
+ 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
+199,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
+210,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.
*/
if (yaffs_check_ff((__u8 *)&pt1, 8)) {
return YAFFS_FAIL;
}
/* Check for a blank/erased chunk.
*/
if (yaffs_check_ff((__u8 *)&pt1, 8)) {
- /* when blank, upper layers want ecc
R
esult to be <= NO_ERROR */
+ /* 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);
}
@@
-242,20
+243,20
@@
int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
/* Check the packed tags mini-ECC and correct if necessary/possible.
*/
/* Check the packed tags mini-ECC and correct if necessary/possible.
*/
- retval = yaffs_check_tags_ecc((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);
}
return rettags(etags, YAFFS_ECC_RESULT_UNFIXED, YAFFS_FAIL);
}
@@
-264,10
+265,10
@@
int nandmtd1_ReadChunkWithTagsFromNAND(yaffs_Device *dev,
*/
pt1.shouldBeFF = 0xFFFFFFFF;
yaffs_unpack_tags1(etags, &pt1);
*/
pt1.shouldBeFF = 0xFFFFFFFF;
yaffs_unpack_tags1(etags, &pt1);
- etags->ecc
R
esult = eccres;
+ 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
+279,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_dev_to_mtd(dev);
{
struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
- int blocksize = dev->param.
nChunksPerBlock * dev->nDataBytesPerC
hunk;
+ 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
+319,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_dev_to_mtd(dev);
{
struct mtd_info *mtd = yaffs_dev_to_mtd(dev);
- int chunkNo = block
No * dev->param.nChunksPerB
lock;
- loff_t addr = (loff_t)chunkNo * dev->
nDataBytesPerC
hunk;
- yaffs_
ExtendedT
ags etags;
+ 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
+337,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;
}