aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2010-01-22 16:22:52 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-02-26 11:56:35 -0500
commit1385858ee07cbfd68c503a10e4a526d24223d465 (patch)
treef0d4a3de0a8f21e0cbbbdab61e7e9f43abe2018f /drivers
parentc3341d0ceb4de1680572024f50233403c6a8b10d (diff)
mtd: nand_bcm: fix hot spin and code duplication
In the branch where pagesize equalled NAND_DATA_ACCESS_SIZE, NumToRead wasn't decremented in the `while (numToRead > 11)' loop. Also the first and last while loops were duplicated in both branches. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Acked-by: Leo Chen <leochen@broadcom.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/nand_bcm_umi.h71
1 files changed, 25 insertions, 46 deletions
diff --git a/drivers/mtd/nand/nand_bcm_umi.h b/drivers/mtd/nand/nand_bcm_umi.h
index 7cec2cd97854..198b304d6f72 100644
--- a/drivers/mtd/nand/nand_bcm_umi.h
+++ b/drivers/mtd/nand/nand_bcm_umi.h
@@ -167,18 +167,27 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
167 int numToRead = 16; /* There are 16 bytes per sector in the OOB */ 167 int numToRead = 16; /* There are 16 bytes per sector in the OOB */
168 168
169 /* ECC is already paused when this function is called */ 169 /* ECC is already paused when this function is called */
170 if (pageSize != NAND_DATA_ACCESS_SIZE) {
171 /* skip BI */
172#if defined(__KERNEL__) && !defined(STANDALONE)
173 *oobp++ = REG_NAND_DATA8;
174#else
175 REG_NAND_DATA8;
176#endif
177 numToRead--;
178 }
170 179
171 if (pageSize == NAND_DATA_ACCESS_SIZE) { 180 while (numToRead > numEccBytes) {
172 while (numToRead > numEccBytes) { 181 /* skip free oob region */
173 /* skip free oob region */
174#if defined(__KERNEL__) && !defined(STANDALONE) 182#if defined(__KERNEL__) && !defined(STANDALONE)
175 *oobp++ = REG_NAND_DATA8; 183 *oobp++ = REG_NAND_DATA8;
176#else 184#else
177 REG_NAND_DATA8; 185 REG_NAND_DATA8;
178#endif 186#endif
179 numToRead--; 187 numToRead--;
180 } 188 }
181 189
190 if (pageSize == NAND_DATA_ACCESS_SIZE) {
182 /* read ECC bytes before BI */ 191 /* read ECC bytes before BI */
183 nand_bcm_umi_bch_resume_read_ecc_calc(); 192 nand_bcm_umi_bch_resume_read_ecc_calc();
184 193
@@ -190,6 +199,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
190#else 199#else
191 eccCalc[eccPos++] = REG_NAND_DATA8; 200 eccCalc[eccPos++] = REG_NAND_DATA8;
192#endif 201#endif
202 numToRead--;
193 } 203 }
194 204
195 nand_bcm_umi_bch_pause_read_ecc_calc(); 205 nand_bcm_umi_bch_pause_read_ecc_calc();
@@ -204,49 +214,18 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
204 numToRead--; 214 numToRead--;
205 } 215 }
206 216
207 /* read ECC bytes */ 217 }
208 nand_bcm_umi_bch_resume_read_ecc_calc(); 218 /* read ECC bytes */
209 while (numToRead) { 219 nand_bcm_umi_bch_resume_read_ecc_calc();
210#if defined(__KERNEL__) && !defined(STANDALONE) 220 while (numToRead) {
211 *oobp = REG_NAND_DATA8;
212 eccCalc[eccPos++] = *oobp;
213 oobp++;
214#else
215 eccCalc[eccPos++] = REG_NAND_DATA8;
216#endif
217 numToRead--;
218 }
219 } else {
220 /* skip BI */
221#if defined(__KERNEL__) && !defined(STANDALONE) 221#if defined(__KERNEL__) && !defined(STANDALONE)
222 *oobp++ = REG_NAND_DATA8; 222 *oobp = REG_NAND_DATA8;
223 eccCalc[eccPos++] = *oobp;
224 oobp++;
223#else 225#else
224 REG_NAND_DATA8; 226 eccCalc[eccPos++] = REG_NAND_DATA8;
225#endif 227#endif
226 numToRead--; 228 numToRead--;
227
228 while (numToRead > numEccBytes) {
229 /* skip free oob region */
230#if defined(__KERNEL__) && !defined(STANDALONE)
231 *oobp++ = REG_NAND_DATA8;
232#else
233 REG_NAND_DATA8;
234#endif
235 numToRead--;
236 }
237
238 /* read ECC bytes */
239 nand_bcm_umi_bch_resume_read_ecc_calc();
240 while (numToRead) {
241#if defined(__KERNEL__) && !defined(STANDALONE)
242 *oobp = REG_NAND_DATA8;
243 eccCalc[eccPos++] = *oobp;
244 oobp++;
245#else
246 eccCalc[eccPos++] = REG_NAND_DATA8;
247#endif
248 numToRead--;
249 }
250 } 229 }
251} 230}
252 231