Mercurial > yaffs-ecoscentric-gpl
annotate packages/fs/yaffs/current/src/yaffs_mtdif2.c @ 425:dea4d7d250ad ecos
Move sources into packages/fs/yaffs/current/src/
| author | Ross Younger <wry@ecoscentric.com> |
|---|---|
| date | Fri, 14 May 2010 16:03:09 +0100 |
| parents | yaffs_mtdif2.c@d94b1449bddc |
| children |
| rev | line source |
|---|---|
| 7 | 1 /* |
| 168 | 2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. |
| 7 | 3 * |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
356
diff
changeset
|
4 * Copyright (C) 2002-2010 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 |
|
45
1f2f55618d63
If kernel/config.h is included in yportenv.h, then yportenv.h must be
marty <marty>
parents:
24
diff
changeset
|
16 #include "yportenv.h" |
| 342 | 17 #include "yaffs_trace.h" |
| 7 | 18 |
| 19 #include "yaffs_mtdif2.h" | |
| 20 | |
| 21 #include "linux/mtd/mtd.h" | |
| 22 #include "linux/types.h" | |
| 23 #include "linux/time.h" | |
| 24 | |
| 25 #include "yaffs_packedtags2.h" | |
| 26 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
27 #include "yaffs_linux.h" |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
28 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
29 /* 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
|
30 * 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
|
31 * 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
|
32 */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
33 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
|
34 const __u8 *data, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
35 const yaffs_ExtendedTags *tags) |
| 7 | 36 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
37 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
|
38 #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17)) |
| 143 | 39 struct mtd_oob_ops ops; |
| 40 #else | |
| 7 | 41 size_t dummy; |
| 143 | 42 #endif |
| 7 | 43 int retval = 0; |
| 44 | |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
45 loff_t addr; |
| 7 | 46 |
| 47 yaffs_PackedTags2 pt; | |
| 48 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
49 int packed_tags_size = dev->param.noTagsECC ? sizeof(pt.t) : sizeof(pt); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
50 void * packed_tags_ptr = dev->param.noTagsECC ? (void *) &pt.t : (void *)&pt; |
| 300 | 51 |
| 76 | 52 T(YAFFS_TRACE_MTD, |
| 53 (TSTR | |
| 54 ("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p" | |
| 55 TENDSTR), chunkInNAND, data, tags)); | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
56 |
| 143 | 57 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
58 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
|
59 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
60 /* 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
|
61 * 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
|
62 * 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
|
63 */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
64 if (!data || !tags) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
65 BUG(); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
66 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
|
67 yaffs_PackedTags2TagsPart *pt2tp; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
68 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
|
69 yaffs_PackTags2TagsPart(pt2tp, tags); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
70 } else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
71 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
|
72 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
73 #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
|
74 ops.mode = MTD_OOB_AUTO; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
75 ops.ooblen = (dev->param.inbandTags) ? 0 : packed_tags_size; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
76 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
|
77 ops.ooboffs = 0; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
78 ops.datbuf = (__u8 *)data; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
79 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
|
80 retval = mtd->write_oob(mtd, addr, &ops); |
| 7 | 81 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
82 #else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
83 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
|
84 retval = |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
85 mtd->write_ecc(mtd, addr, dev->nDataBytesPerChunk, |
| 300 | 86 &dummy, data, (__u8 *) packed_tags_ptr, NULL); |
| 76 | 87 } else { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
88 retval = |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
89 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
|
90 data); |
| 7 | 91 } |
| 143 | 92 #endif |
| 7 | 93 |
| 76 | 94 if (retval == 0) |
| 95 return YAFFS_OK; | |
| 96 else | |
| 97 return YAFFS_FAIL; | |
| 7 | 98 } |
| 99 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
100 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
|
101 __u8 *data, yaffs_ExtendedTags *tags) |
| 7 | 102 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
103 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
|
104 #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17)) |
| 143 | 105 struct mtd_oob_ops ops; |
| 106 #endif | |
| 7 | 107 size_t dummy; |
| 76 | 108 int retval = 0; |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
109 int localData = 0; |
| 7 | 110 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
111 loff_t addr = ((loff_t) chunkInNAND) * dev->param.totalBytesPerChunk; |
| 76 | 112 |
| 7 | 113 yaffs_PackedTags2 pt; |
| 114 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
115 int packed_tags_size = dev->param.noTagsECC ? sizeof(pt.t) : sizeof(pt); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
116 void * packed_tags_ptr = dev->param.noTagsECC ? (void *) &pt.t: (void *)&pt; |
| 300 | 117 |
| 76 | 118 T(YAFFS_TRACE_MTD, |
| 119 (TSTR | |
|
126
2e7fd6d40037
Fix a couple of mistakes in TRACE/Error messages. Update copyright date.
wookey <wookey>
parents:
103
diff
changeset
|
120 ("nandmtd2_ReadChunkWithTagsFromNAND chunk %d data %p tags %p" |
| 76 | 121 TENDSTR), chunkInNAND, data, tags)); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
122 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
123 if (dev->param.inbandTags) { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
124 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
125 if (!data) { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
126 localData = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
127 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
|
128 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
129 |
| 7 | 130 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
131 } |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
132 |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
133 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
134 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
135 if (dev->param.inbandTags || (data && !tags)) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
136 retval = mtd->read(mtd, addr, dev->param.totalBytesPerChunk, |
| 143 | 137 &dummy, data); |
| 138 else if (tags) { | |
| 139 ops.mode = MTD_OOB_AUTO; | |
| 300 | 140 ops.ooblen = packed_tags_size; |
| 141 ops.len = data ? dev->nDataBytesPerChunk : packed_tags_size; | |
| 143 | 142 ops.ooboffs = 0; |
| 143 ops.datbuf = data; | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
144 ops.oobbuf = yaffs_DeviceToContext(dev)->spareBuffer; |
| 143 | 145 retval = mtd->read_oob(mtd, addr, &ops); |
| 146 } | |
| 147 #else | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
148 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
|
149 |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
150 retval = mtd->read_ecc(mtd, addr, dev->nDataBytesPerChunk, |
| 76 | 151 &dummy, data, dev->spareBuffer, |
| 152 NULL); | |
| 153 } else { | |
| 154 if (data) | |
| 155 retval = | |
|
146
1a32267ef1c1
Add large NAND support and improve retirement handling
charles <charles>
parents:
143
diff
changeset
|
156 mtd->read(mtd, addr, dev->nDataBytesPerChunk, &dummy, |
| 76 | 157 data); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
158 if (!dev->param.inbandTags && tags) |
| 76 | 159 retval = |
| 160 mtd->read_oob(mtd, addr, mtd->oobsize, &dummy, | |
| 161 dev->spareBuffer); | |
| 7 | 162 } |
| 143 | 163 #endif |
| 7 | 164 |
| 76 | 165 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
166 if (dev->param.inbandTags) { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
167 if (tags) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
168 yaffs_PackedTags2TagsPart *pt2tp; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
169 pt2tp = (yaffs_PackedTags2TagsPart *)&data[dev->nDataBytesPerChunk]; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
170 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
|
171 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
172 } else { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
173 if (tags) { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
174 memcpy(packed_tags_ptr, yaffs_DeviceToContext(dev)->spareBuffer, packed_tags_size); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
175 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
|
176 } |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
177 } |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
197
diff
changeset
|
178 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
179 if (localData) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
180 yaffs_ReleaseTempBuffer(dev, data, __LINE__); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
181 |
|
413
d94b1449bddc
yaffs: Integrate Android tree differences
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
182 if (tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR) { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
223
diff
changeset
|
183 tags->eccResult = YAFFS_ECC_RESULT_UNFIXED; |
|
413
d94b1449bddc
yaffs: Integrate Android tree differences
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
184 dev->eccUnfixed++; |
|
d94b1449bddc
yaffs: Integrate Android tree differences
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
185 } |
|
d94b1449bddc
yaffs: Integrate Android tree differences
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
186 if(tags && retval == -EUCLEAN && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR) { |
|
d94b1449bddc
yaffs: Integrate Android tree differences
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
187 tags->eccResult = YAFFS_ECC_RESULT_FIXED; |
|
d94b1449bddc
yaffs: Integrate Android tree differences
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
188 dev->eccFixed++; |
|
d94b1449bddc
yaffs: Integrate Android tree differences
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
189 } |
| 76 | 190 if (retval == 0) |
| 191 return YAFFS_OK; | |
| 192 else | |
| 193 return YAFFS_FAIL; | |
| 7 | 194 } |
| 195 | |
| 196 int nandmtd2_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo) | |
| 197 { | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
198 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; |
| 7 | 199 int retval; |
| 76 | 200 T(YAFFS_TRACE_MTD, |
| 201 (TSTR("nandmtd2_MarkNANDBlockBad %d" TENDSTR), blockNo)); | |
| 7 | 202 |
| 76 | 203 retval = |
| 204 mtd->block_markbad(mtd, | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
205 blockNo * dev->param.nChunksPerBlock * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
206 dev->param.totalBytesPerChunk); |
| 76 | 207 |
| 208 if (retval == 0) | |
| 209 return YAFFS_OK; | |
| 210 else | |
| 211 return YAFFS_FAIL; | |
| 7 | 212 |
| 213 } | |
| 214 | |
| 76 | 215 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
|
216 yaffs_BlockState *state, __u32 *sequenceNumber) |
| 7 | 217 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
218 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd; |
| 7 | 219 int retval; |
| 76 | 220 |
| 221 T(YAFFS_TRACE_MTD, | |
| 222 (TSTR("nandmtd2_QueryNANDBlock %d" TENDSTR), blockNo)); | |
| 223 retval = | |
| 224 mtd->block_isbad(mtd, | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
225 blockNo * dev->param.nChunksPerBlock * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
226 dev->param.totalBytesPerChunk); |
| 76 | 227 |
| 228 if (retval) { | |
| 229 T(YAFFS_TRACE_MTD, (TSTR("block is bad" TENDSTR))); | |
| 230 | |
| 7 | 231 *state = YAFFS_BLOCK_STATE_DEAD; |
| 232 *sequenceNumber = 0; | |
| 76 | 233 } else { |
| 7 | 234 yaffs_ExtendedTags t; |
| 76 | 235 nandmtd2_ReadChunkWithTagsFromNAND(dev, |
| 236 blockNo * | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
343
diff
changeset
|
237 dev->param.nChunksPerBlock, NULL, |
| 76 | 238 &t); |
| 239 | |
| 240 if (t.chunkUsed) { | |
| 241 *sequenceNumber = t.sequenceNumber; | |
| 242 *state = YAFFS_BLOCK_STATE_NEEDS_SCANNING; | |
| 243 } else { | |
| 244 *sequenceNumber = 0; | |
| 245 *state = YAFFS_BLOCK_STATE_EMPTY; | |
| 7 | 246 } |
| 247 } | |
| 76 | 248 T(YAFFS_TRACE_MTD, |
| 249 (TSTR("block is bad seq %d state %d" TENDSTR), *sequenceNumber, | |
| 250 *state)); | |
| 7 | 251 |
| 76 | 252 if (retval == 0) |
| 253 return YAFFS_OK; | |
| 254 else | |
| 255 return YAFFS_FAIL; | |
| 7 | 256 } |
| 257 |
