Mercurial > yaffs-ecoscentric-gpl
annotate yaffs_mtdif2.c @ 391:d0784604eafd
Fix typo (and check git is working)
| author | Wookey <wookey@wookware.org> |
|---|---|
| date | Thu, 18 Mar 2010 21:44:53 +0000 |
| parents | 7ee0cc4ba753 |
| children | b5309c9b6d7f |
| rev | line source |
|---|---|
| 7 | 1 /* |
| 168 | 2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. |
| 7 | 3 * |
| 168 | 4 * Copyright (C) 2002-2007 Aleph One Ltd. |
| 7 | 5 * for Toby Churchill Ltd and Brightstar Engineering |
| 6 * | |
| 7 * Created by Charles Manning <charles@aleph1.co.uk> | |
| 8 * | |
| 9 * This program is free software; you can redistribute it and/or modify | |
| 10 * it under the terms of the GNU General Public License version 2 as | |
| 11 * published by the Free Software Foundation. | |
| 12 */ | |
| 13 | |
| 76 | 14 /* mtd interface for YAFFS2 */ |
| 7 | 15 |
| 76 | 16 const char *yaffs_mtdif2_c_version = |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
17 "$Id: yaffs_mtdif2.c,v 1.27 2010-02-18 01:18:04 charles Exp $"; |
| 76 | 18 |
|
45
1f2f55618d63
If kernel/config.h is included in yportenv.h, then yportenv.h must be
marty <marty>
parents:
24
diff
changeset
|
19 #include "yportenv.h" |
| 342 | 20 #include "yaffs_trace.h" |
| 7 | 21 |
| 22 #include "yaffs_mtdif2.h" | |
| 23 | |
| 24 #include "linux/mtd/mtd.h" | |
| 25 #include "linux/types.h" | |
| 26 #include "linux/time.h" | |
| 27 | |
| 28 #include "yaffs_packedtags2.h" | |
| 29 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
30 #include "yaffs_linux.h" |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
31 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
32 /* NB For use with inband tags.... |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
33 * We assume that the data buffer is of size totalBytersPerChunk so that we can also |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
34 * use it to load the tags. |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
35 */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
36 int nandmtd2_WriteChunkWithTagsToNAND(yaffs_Device *dev, int chunkInNAND, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
37 const __u8 *data, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
38 const yaffs_ExtendedTags *tags) |
| 7 | 39 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
40 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
41 #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17)) |
| 143 | 42 struct mtd_oob_ops ops; |
| 43 #else | |
| 7 | 44 size_t dummy; |
| 143 | 45 #endif |
| 7 | 46 int retval = 0; |
| 47 | |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
48 loff_t addr; |
| 7 | 49 |
| 50 yaffs_PackedTags2 pt; | |
| 51 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
52 int packed_tags_size = dev->param.noTagsECC ? sizeof(pt.t) : sizeof(pt); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
53 void * packed_tags_ptr = dev->param.noTagsECC ? (void *) &pt.t : (void *)&pt; |
| 300 | 54 |
| 76 | 55 T(YAFFS_TRACE_MTD, |
| 56 (TSTR | |
| 57 ("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p" | |
| 58 TENDSTR), chunkInNAND, data, tags)); | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
59 |
| 143 | 60 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
61 addr = ((loff_t) chunkInNAND) * dev->param.totalBytesPerChunk; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
62 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
63 /* For yaffs2 writing there must be both data and tags. |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
64 * If we're using inband tags, then the tags are stuffed into |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
65 * the end of the data buffer. |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
66 */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
67 if (!data || !tags) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
68 BUG(); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
69 else if (dev->param.inbandTags) { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
70 yaffs_PackedTags2TagsPart *pt2tp; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
71 pt2tp = (yaffs_PackedTags2TagsPart *)(data + dev->nDataBytesPerChunk); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
72 yaffs_PackTags2TagsPart(pt2tp, tags); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
73 } else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
74 yaffs_PackTags2(&pt, tags, !dev->param.noTagsECC); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
75 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
76 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
77 ops.mode = MTD_OOB_AUTO; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
78 ops.ooblen = (dev->param.inbandTags) ? 0 : packed_tags_size; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
79 ops.len = dev->param.totalBytesPerChunk; |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
80 ops.ooboffs = 0; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
81 ops.datbuf = (__u8 *)data; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
82 ops.oobbuf = (dev->param.inbandTags) ? NULL : packed_tags_ptr; |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
83 retval = mtd->write_oob(mtd, addr, &ops); |
| 7 | 84 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
85 #else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
86 if (!dev->param.inbandTags) { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
87 retval = |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
88 mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk, |
| 300 | 89 &dummy, data, (__u8 *) packed_tags_ptr, NULL); |
| 76 | 90 } else { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
91 retval = |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
92 mtd->write(mtd, addr, dev->param.totalBytesPerChunk, &dummy, |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
93 data); |
| 7 | 94 } |
| 143 | 95 #endif |
| 7 | 96 |
| 76 | 97 if (retval == 0) |
| 98 return YAFFS_OK; | |
| 99 else | |
| 100 return YAFFS_FAIL; | |
| 7 | 101 } |
| 102 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
103 int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device *dev, int chunkInNAND, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
104 __u8 *data, yaffs_ExtendedTags *tags) |
| 7 | 105 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
106 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
107 #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17)) |
| 143 | 108 struct mtd_oob_ops ops; |
| 109 #endif | |
| 7 | 110 size_t dummy; |
| 76 | 111 int retval = 0; |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
112 int localData = 0; |
| 7 | 113 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
114 loff_t addr = ((loff_t) chunkInNAND) * dev->param.totalBytesPerChunk; |
| 76 | 115 |
| 7 | 116 yaffs_PackedTags2 pt; |
| 117 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
118 int packed_tags_size = dev->param.noTagsECC ? sizeof(pt.t) : sizeof(pt); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
119 void * packed_tags_ptr = dev->param.noTagsECC ? (void *) &pt.t: (void *)&pt; |
| 300 | 120 |
| 76 | 121 T(YAFFS_TRACE_MTD, |
| 122 (TSTR | |
|
126
2e7fd6d40037
Fix a couple of mistakes in TRACE/Error messages. Update copyright date.
wookey <wookey>
parents:
103
diff
changeset
|
123 ("nandmtd2_ReadChunkWithTagsFromNAND chunk %d data %p tags %p" |
| 76 | 124 TENDSTR), chunkInNAND, data, tags)); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
125 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
126 if (dev->param.inbandTags) { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
127 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
128 if (!data) { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
129 localData = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
130 data = yaffs_GetTempBuffer(dev, __LINE__); |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
131 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
132 |
| 7 | 133 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
134 } |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
135 |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
136 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
137 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
138 if (dev->param.inbandTags || (data && !tags)) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
139 retval = mtd->read(mtd, addr, dev->param.totalBytesPerChunk, |
| 143 | 140 &dummy, data); |
| 141 else if (tags) { | |
| 142 ops.mode = MTD_OOB_AUTO; | |
| 300 | 143 ops.ooblen = packed_tags_size; |
| 144 ops.len = data ? dev->nDataBytesPerChunk : packed_tags_size; | |
| 143 | 145 ops.ooboffs = 0; |
| 146 ops.datbuf = data; | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
147 ops.oobbuf = yaffs_DeviceToContext(dev)->spareBuffer; |
| 143 | 148 retval = mtd->read_oob(mtd, addr, &ops); |
| 149 } | |
| 150 #else | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
151 if (!dev->param.inbandTags && data && tags) { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
152 |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
153 retval = mtd->read_ecc(mtd, addr, dev->nDataBytesPerChunk, |
| 76 | 154 &dummy, data, dev->spareBuffer, |
| 155 NULL); | |
| 156 } else { | |
| 157 if (data) | |
| 158 retval = | |
|
146
1a32267ef1c1
Add large NAND support and improve retirement handling
charles <charles>
parents:
143
diff
changeset
|
159 mtd->read(mtd, addr, dev->nDataBytesPerChunk, &dummy, |
| 76 | 160 data); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
161 if (!dev->param.inbandTags && tags) |
| 76 | 162 retval = |
| 163 mtd->read_oob(mtd, addr, mtd->oobsize, &dummy, | |
| 164 dev->spareBuffer); | |
| 7 | 165 } |
| 143 | 166 #endif |
| 7 | 167 |
| 76 | 168 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
169 if (dev->param.inbandTags) { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
170 if (tags) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
171 yaffs_PackedTags2TagsPart *pt2tp; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
172 pt2tp = (yaffs_PackedTags2TagsPart *)&data[dev->nDataBytesPerChunk]; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
173 yaffs_UnpackTags2TagsPart(tags, pt2tp); |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
174 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
175 } else { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
176 if (tags) { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
177 memcpy(packed_tags_ptr, yaffs_DeviceToContext(dev)->spareBuffer, packed_tags_size); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
178 yaffs_UnpackTags2(tags, &pt, !dev->param.noTagsECC); |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
179 } |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
180 } |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
197
diff
changeset
|
181 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
182 if (localData) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
183 yaffs_ReleaseTempBuffer(dev, data, __LINE__); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
184 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
185 if (tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
186 tags->eccResult = YAFFS_ECC_RESULT_UNFIXED; |
| 76 | 187 if (retval == 0) |
| 188 return YAFFS_OK; | |
| 189 else | |
| 190 return YAFFS_FAIL; | |
| 7 | 191 } |
| 192 | |
| 193 int nandmtd2_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo) | |
| 194 { | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
195 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; |
| 7 | 196 int retval; |
| 76 | 197 T(YAFFS_TRACE_MTD, |
| 198 (TSTR("nandmtd2_MarkNANDBlockBad %d" TENDSTR), blockNo)); | |
| 7 | 199 |
| 76 | 200 retval = |
| 201 mtd->block_markbad(mtd, | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
202 blockNo * dev->param.nChunksPerBlock * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
203 dev->param.totalBytesPerChunk); |
| 76 | 204 |
| 205 if (retval == 0) | |
| 206 return YAFFS_OK; | |
| 207 else | |
| 208 return YAFFS_FAIL; | |
| 7 | 209 |
| 210 } | |
| 211 | |
| 76 | 212 int nandmtd2_QueryNANDBlock(struct yaffs_DeviceStruct *dev, int blockNo, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
213 yaffs_BlockState *state, __u32 *sequenceNumber) |
| 7 | 214 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
215 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; |
| 7 | 216 int retval; |
| 76 | 217 |
| 218 T(YAFFS_TRACE_MTD, | |
| 219 (TSTR("nandmtd2_QueryNANDBlock %d" TENDSTR), blockNo)); | |
| 220 retval = | |
| 221 mtd->block_isbad(mtd, | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
222 blockNo * dev->param.nChunksPerBlock * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
223 dev->param.totalBytesPerChunk); |
| 76 | 224 |
| 225 if (retval) { | |
| 226 T(YAFFS_TRACE_MTD, (TSTR("block is bad" TENDSTR))); | |
| 227 | |
| 7 | 228 *state = YAFFS_BLOCK_STATE_DEAD; |
| 229 *sequenceNumber = 0; | |
| 76 | 230 } else { |
| 7 | 231 yaffs_ExtendedTags t; |
| 76 | 232 nandmtd2_ReadChunkWithTagsFromNAND(dev, |
| 233 blockNo * | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
234 dev->param.nChunksPerBlock, NULL, |
| 76 | 235 &t); |
| 236 | |
| 237 if (t.chunkUsed) { | |
| 238 *sequenceNumber = t.sequenceNumber; | |
| 239 *state = YAFFS_BLOCK_STATE_NEEDS_SCANNING; | |
| 240 } else { | |
| 241 *sequenceNumber = 0; | |
| 242 *state = YAFFS_BLOCK_STATE_EMPTY; | |
| 7 | 243 } |
| 244 } | |
| 76 | 245 T(YAFFS_TRACE_MTD, |
| 246 (TSTR("block is bad seq %d state %d" TENDSTR), *sequenceNumber, | |
| 247 *state)); | |
| 7 | 248 |
| 76 | 249 if (retval == 0) |
| 250 return YAFFS_OK; | |
| 251 else | |
| 252 return YAFFS_FAIL; | |
| 7 | 253 } |
| 254 |
