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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
1 /*
168
b8f20fdc3a58 normalise licence headers and attributions
wookey <wookey>
parents: 153
diff changeset
2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
3 *
409
b5309c9b6d7f yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents: 356
diff changeset
4 * Copyright (C) 2002-2010 Aleph One Ltd.
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
5 * for Toby Churchill Ltd and Brightstar Engineering
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
6 *
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
7 * Created by Charles Manning <charles@aleph1.co.uk>
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
8 *
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
10 * it under the terms of the GNU General Public License version 2 as
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
11 * published by the Free Software Foundation.
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
12 */
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
13
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
14 /* mtd interface for YAFFS2 */
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
ce702882929d Move tracing out of yportenv.h
charles <charles>
parents: 300
diff changeset
17 #include "yaffs_trace.h"
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
18
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
19 #include "yaffs_mtdif2.h"
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
20
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
21 #include "linux/mtd/mtd.h"
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
22 #include "linux/types.h"
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
23 #include "linux/time.h"
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
24
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
25 #include "yaffs_packedtags2.h"
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
39 struct mtd_oob_ops ops;
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
40 #else
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
41 size_t dummy;
143
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
42 #endif
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
43 int retval = 0;
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
46
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
47 yaffs_PackedTags2 pt;
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
4d9d442da93f Allow the disabling of tags ECC
charles <charles>
parents: 271
diff changeset
51
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
52 T(YAFFS_TRACE_MTD,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
53 (TSTR
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
54 ("nandmtd2_WriteChunkWithTagsToNAND chunk %d data %p tags %p"
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
4d9d442da93f Allow the disabling of tags ECC
charles <charles>
parents: 271
diff changeset
86 &dummy, data, (__u8 *) packed_tags_ptr, NULL);
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
91 }
143
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
92 #endif
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
93
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
94 if (retval == 0)
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
95 return YAFFS_OK;
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
96 else
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
97 return YAFFS_FAIL;
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
98 }
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
105 struct mtd_oob_ops ops;
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
106 #endif
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
107 size_t dummy;
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
112
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
113 yaffs_PackedTags2 pt;
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
4d9d442da93f Allow the disabling of tags ECC
charles <charles>
parents: 271
diff changeset
117
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
118 T(YAFFS_TRACE_MTD,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
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
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
137 &dummy, data);
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
138 else if (tags) {
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
139 ops.mode = MTD_OOB_AUTO;
300
4d9d442da93f Allow the disabling of tags ECC
charles <charles>
parents: 271
diff changeset
140 ops.ooblen = packed_tags_size;
4d9d442da93f Allow the disabling of tags ECC
charles <charles>
parents: 271
diff changeset
141 ops.len = data ? dev->nDataBytesPerChunk : packed_tags_size;
143
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
142 ops.ooboffs = 0;
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
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
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
145 retval = mtd->read_oob(mtd, addr, &ops);
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
146 }
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
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
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
151 &dummy, data, dev->spareBuffer,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
152 NULL);
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
153 } else {
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
154 if (data)
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
157 data);
356
7ee0cc4ba753 Rationalise context and parameter handling
charles <charles>
parents: 343
diff changeset
158 if (!dev->param.inbandTags && tags)
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
159 retval =
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
160 mtd->read_oob(mtd, addr, mtd->oobsize, &dummy,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
161 dev->spareBuffer);
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
162 }
143
bec3d6bed11a Interworking with 2.6.18 kernel enabled
vwool <vwool>
parents: 142
diff changeset
163 #endif
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
164
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
190 if (retval == 0)
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
191 return YAFFS_OK;
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
192 else
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
193 return YAFFS_FAIL;
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
194 }
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
195
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
196 int nandmtd2_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
197 {
356
7ee0cc4ba753 Rationalise context and parameter handling
charles <charles>
parents: 343
diff changeset
198 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd;
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
199 int retval;
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
200 T(YAFFS_TRACE_MTD,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
201 (TSTR("nandmtd2_MarkNANDBlockBad %d" TENDSTR), blockNo));
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
202
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
203 retval =
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
207
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
208 if (retval == 0)
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
209 return YAFFS_OK;
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
210 else
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
211 return YAFFS_FAIL;
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
212
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
213 }
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
214
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
217 {
356
7ee0cc4ba753 Rationalise context and parameter handling
charles <charles>
parents: 343
diff changeset
218 struct mtd_info *mtd = yaffs_DeviceToContext(dev)->mtd;
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
219 int retval;
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
220
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
221 T(YAFFS_TRACE_MTD,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
222 (TSTR("nandmtd2_QueryNANDBlock %d" TENDSTR), blockNo));
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
223 retval =
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
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
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
227
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
228 if (retval) {
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
229 T(YAFFS_TRACE_MTD, (TSTR("block is bad" TENDSTR)));
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
230
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
231 *state = YAFFS_BLOCK_STATE_DEAD;
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
232 *sequenceNumber = 0;
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
233 } else {
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
234 yaffs_ExtendedTags t;
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
235 nandmtd2_ReadChunkWithTagsFromNAND(dev,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
236 blockNo *
356
7ee0cc4ba753 Rationalise context and parameter handling
charles <charles>
parents: 343
diff changeset
237 dev->param.nChunksPerBlock, NULL,
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
238 &t);
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
239
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
240 if (t.chunkUsed) {
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
241 *sequenceNumber = t.sequenceNumber;
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
242 *state = YAFFS_BLOCK_STATE_NEEDS_SCANNING;
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
243 } else {
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
244 *sequenceNumber = 0;
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
245 *state = YAFFS_BLOCK_STATE_EMPTY;
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
246 }
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
247 }
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
248 T(YAFFS_TRACE_MTD,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
249 (TSTR("block is bad seq %d state %d" TENDSTR), *sequenceNumber,
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
250 *state));
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
251
76
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
252 if (retval == 0)
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
253 return YAFFS_OK;
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
254 else
0113df80498c lindent
marty <marty>
parents: 57
diff changeset
255 return YAFFS_FAIL;
7
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
256 }
9fd733a84a74 *** empty log message ***
charles <charles>
parents:
diff changeset
257