aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nftlcore.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2005-11-07 06:15:26 -0500
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-07 07:37:38 -0500
commit97894cda5773e59bd13e87b72077751099419a9f (patch)
tree9a039ab8c122ae9a4f64d285e2da0efd1356789e /drivers/mtd/nftlcore.c
parentb95f9609c761a14d1e7be1a89f2a66399b5ae343 (diff)
[MTD] core: Clean up trailing white spaces
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nftlcore.c')
-rw-r--r--drivers/mtd/nftlcore.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index b2014043634f..89d662999e7b 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -1,7 +1,7 @@
1/* Linux driver for NAND Flash Translation Layer */ 1/* Linux driver for NAND Flash Translation Layer */
2/* (c) 1999 Machine Vision Holdings, Inc. */ 2/* (c) 1999 Machine Vision Holdings, Inc. */
3/* Author: David Woodhouse <dwmw2@infradead.org> */ 3/* Author: David Woodhouse <dwmw2@infradead.org> */
4/* $Id: nftlcore.c,v 1.97 2004/11/16 18:28:59 dwmw2 Exp $ */ 4/* $Id: nftlcore.c,v 1.98 2005/11/07 11:14:21 gleixner Exp $ */
5 5
6/* 6/*
7 The contents of this file are distributed under the GNU General 7 The contents of this file are distributed under the GNU General
@@ -101,14 +101,14 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
101 101
102 if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) { 102 if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) {
103 /* 103 /*
104 Oh no we don't have 104 Oh no we don't have
105 mbd.size == heads * cylinders * sectors 105 mbd.size == heads * cylinders * sectors
106 */ 106 */
107 printk(KERN_WARNING "NFTL: cannot calculate a geometry to " 107 printk(KERN_WARNING "NFTL: cannot calculate a geometry to "
108 "match size of 0x%lx.\n", nftl->mbd.size); 108 "match size of 0x%lx.\n", nftl->mbd.size);
109 printk(KERN_WARNING "NFTL: using C:%d H:%d S:%d " 109 printk(KERN_WARNING "NFTL: using C:%d H:%d S:%d "
110 "(== 0x%lx sects)\n", 110 "(== 0x%lx sects)\n",
111 nftl->cylinders, nftl->heads , nftl->sectors, 111 nftl->cylinders, nftl->heads , nftl->sectors,
112 (long)nftl->cylinders * (long)nftl->heads * 112 (long)nftl->cylinders * (long)nftl->heads *
113 (long)nftl->sectors ); 113 (long)nftl->sectors );
114 } 114 }
@@ -178,7 +178,7 @@ static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate )
178 178
179 if (!silly--) { 179 if (!silly--) {
180 printk("Argh! No free blocks found! LastFreeEUN = %d, " 180 printk("Argh! No free blocks found! LastFreeEUN = %d, "
181 "FirstEUN = %d\n", nftl->LastFreeEUN, 181 "FirstEUN = %d\n", nftl->LastFreeEUN,
182 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)); 182 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN));
183 return 0xffff; 183 return 0xffff;
184 } 184 }
@@ -210,7 +210,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
210 "Virtual Unit Chain %d!\n", thisVUC); 210 "Virtual Unit Chain %d!\n", thisVUC);
211 return BLOCK_NIL; 211 return BLOCK_NIL;
212 } 212 }
213 213
214 /* Scan to find the Erase Unit which holds the actual data for each 214 /* Scan to find the Erase Unit which holds the actual data for each
215 512-byte block within the Chain. 215 512-byte block within the Chain.
216 */ 216 */
@@ -227,7 +227,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
227 if (block == 2) { 227 if (block == 2) {
228 foldmark = oob.u.c.FoldMark | oob.u.c.FoldMark1; 228 foldmark = oob.u.c.FoldMark | oob.u.c.FoldMark1;
229 if (foldmark == FOLD_MARK_IN_PROGRESS) { 229 if (foldmark == FOLD_MARK_IN_PROGRESS) {
230 DEBUG(MTD_DEBUG_LEVEL1, 230 DEBUG(MTD_DEBUG_LEVEL1,
231 "Write Inhibited on EUN %d\n", thisEUN); 231 "Write Inhibited on EUN %d\n", thisEUN);
232 inplace = 0; 232 inplace = 0;
233 } else { 233 } else {
@@ -249,7 +249,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
249 if (!BlockFreeFound[block]) 249 if (!BlockFreeFound[block])
250 BlockMap[block] = thisEUN; 250 BlockMap[block] = thisEUN;
251 else 251 else
252 printk(KERN_WARNING 252 printk(KERN_WARNING
253 "SECTOR_USED found after SECTOR_FREE " 253 "SECTOR_USED found after SECTOR_FREE "
254 "in Virtual Unit Chain %d for block %d\n", 254 "in Virtual Unit Chain %d for block %d\n",
255 thisVUC, block); 255 thisVUC, block);
@@ -258,7 +258,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
258 if (!BlockFreeFound[block]) 258 if (!BlockFreeFound[block])
259 BlockMap[block] = BLOCK_NIL; 259 BlockMap[block] = BLOCK_NIL;
260 else 260 else
261 printk(KERN_WARNING 261 printk(KERN_WARNING
262 "SECTOR_DELETED found after SECTOR_FREE " 262 "SECTOR_DELETED found after SECTOR_FREE "
263 "in Virtual Unit Chain %d for block %d\n", 263 "in Virtual Unit Chain %d for block %d\n",
264 thisVUC, block); 264 thisVUC, block);
@@ -277,14 +277,14 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
277 thisVUC); 277 thisVUC);
278 return BLOCK_NIL; 278 return BLOCK_NIL;
279 } 279 }
280 280
281 thisEUN = nftl->ReplUnitTable[thisEUN]; 281 thisEUN = nftl->ReplUnitTable[thisEUN];
282 } 282 }
283 283
284 if (inplace) { 284 if (inplace) {
285 /* We're being asked to be a fold-in-place. Check 285 /* We're being asked to be a fold-in-place. Check
286 that all blocks which actually have data associated 286 that all blocks which actually have data associated
287 with them (i.e. BlockMap[block] != BLOCK_NIL) are 287 with them (i.e. BlockMap[block] != BLOCK_NIL) are
288 either already present or SECTOR_FREE in the target 288 either already present or SECTOR_FREE in the target
289 block. If not, we're going to have to fold out-of-place 289 block. If not, we're going to have to fold out-of-place
290 anyway. 290 anyway.
@@ -297,7 +297,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
297 "block %d was %x lastEUN, " 297 "block %d was %x lastEUN, "
298 "and is in EUN %d (%s) %d\n", 298 "and is in EUN %d (%s) %d\n",
299 thisVUC, block, BlockLastState[block], 299 thisVUC, block, BlockLastState[block],
300 BlockMap[block], 300 BlockMap[block],
301 BlockMap[block]== targetEUN ? "==" : "!=", 301 BlockMap[block]== targetEUN ? "==" : "!=",
302 targetEUN); 302 targetEUN);
303 inplace = 0; 303 inplace = 0;
@@ -314,17 +314,17 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
314 inplace = 0; 314 inplace = 0;
315 } 315 }
316 } 316 }
317 317
318 if (!inplace) { 318 if (!inplace) {
319 DEBUG(MTD_DEBUG_LEVEL1, "Cannot fold Virtual Unit Chain %d in place. " 319 DEBUG(MTD_DEBUG_LEVEL1, "Cannot fold Virtual Unit Chain %d in place. "
320 "Trying out-of-place\n", thisVUC); 320 "Trying out-of-place\n", thisVUC);
321 /* We need to find a targetEUN to fold into. */ 321 /* We need to find a targetEUN to fold into. */
322 targetEUN = NFTL_findfreeblock(nftl, 1); 322 targetEUN = NFTL_findfreeblock(nftl, 1);
323 if (targetEUN == BLOCK_NIL) { 323 if (targetEUN == BLOCK_NIL) {
324 /* Ouch. Now we're screwed. We need to do a 324 /* Ouch. Now we're screwed. We need to do a
325 fold-in-place of another chain to make room 325 fold-in-place of another chain to make room
326 for this one. We need a better way of selecting 326 for this one. We need a better way of selecting
327 which chain to fold, because makefreeblock will 327 which chain to fold, because makefreeblock will
328 only ask us to fold the same one again. 328 only ask us to fold the same one again.
329 */ 329 */
330 printk(KERN_WARNING 330 printk(KERN_WARNING
@@ -338,7 +338,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
338 chain by selecting the longer one */ 338 chain by selecting the longer one */
339 oob.u.c.FoldMark = oob.u.c.FoldMark1 = cpu_to_le16(FOLD_MARK_IN_PROGRESS); 339 oob.u.c.FoldMark = oob.u.c.FoldMark1 = cpu_to_le16(FOLD_MARK_IN_PROGRESS);
340 oob.u.c.unused = 0xffffffff; 340 oob.u.c.unused = 0xffffffff;
341 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8, 341 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8,
342 8, &retlen, (char *)&oob.u); 342 8, &retlen, (char *)&oob.u);
343 } 343 }
344 344
@@ -361,14 +361,14 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
361 happen in case of media errors or deleted blocks) */ 361 happen in case of media errors or deleted blocks) */
362 if (BlockMap[block] == BLOCK_NIL) 362 if (BlockMap[block] == BLOCK_NIL)
363 continue; 363 continue;
364 364
365 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512), 365 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512),
366 512, &retlen, movebuf); 366 512, &retlen, movebuf);
367 if (ret < 0) { 367 if (ret < 0) {
368 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block]) 368 ret = MTD_READ(nftl->mbd.mtd, (nftl->EraseSize * BlockMap[block])
369 + (block * 512), 512, &retlen, 369 + (block * 512), 512, &retlen,
370 movebuf); 370 movebuf);
371 if (ret != -EIO) 371 if (ret != -EIO)
372 printk("Error went away on retry.\n"); 372 printk("Error went away on retry.\n");
373 } 373 }
374 memset(&oob, 0xff, sizeof(struct nftl_oob)); 374 memset(&oob, 0xff, sizeof(struct nftl_oob));
@@ -376,18 +376,18 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
376 MTD_WRITEECC(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + (block * 512), 376 MTD_WRITEECC(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + (block * 512),
377 512, &retlen, movebuf, (char *)&oob, &nftl->oobinfo); 377 512, &retlen, movebuf, (char *)&oob, &nftl->oobinfo);
378 } 378 }
379 379
380 /* add the header so that it is now a valid chain */ 380 /* add the header so that it is now a valid chain */
381 oob.u.a.VirtUnitNum = oob.u.a.SpareVirtUnitNum 381 oob.u.a.VirtUnitNum = oob.u.a.SpareVirtUnitNum
382 = cpu_to_le16(thisVUC); 382 = cpu_to_le16(thisVUC);
383 oob.u.a.ReplUnitNum = oob.u.a.SpareReplUnitNum = 0xffff; 383 oob.u.a.ReplUnitNum = oob.u.a.SpareReplUnitNum = 0xffff;
384 384
385 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 8, 385 MTD_WRITEOOB(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + 8,
386 8, &retlen, (char *)&oob.u); 386 8, &retlen, (char *)&oob.u);
387 387
388 /* OK. We've moved the whole lot into the new block. Now we have to free the original blocks. */ 388 /* OK. We've moved the whole lot into the new block. Now we have to free the original blocks. */
389 389
390 /* At this point, we have two different chains for this Virtual Unit, and no way to tell 390 /* At this point, we have two different chains for this Virtual Unit, and no way to tell
391 them apart. If we crash now, we get confused. However, both contain the same data, so we 391 them apart. If we crash now, we get confused. However, both contain the same data, so we
392 shouldn't actually lose data in this case. It's just that when we load up on a medium which 392 shouldn't actually lose data in this case. It's just that when we load up on a medium which
393 has duplicate chains, we need to free one of the chains because it's not necessary any more. 393 has duplicate chains, we need to free one of the chains because it's not necessary any more.
@@ -395,7 +395,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
395 thisEUN = nftl->EUNtable[thisVUC]; 395 thisEUN = nftl->EUNtable[thisVUC];
396 DEBUG(MTD_DEBUG_LEVEL1,"Want to erase\n"); 396 DEBUG(MTD_DEBUG_LEVEL1,"Want to erase\n");
397 397
398 /* For each block in the old chain (except the targetEUN of course), 398 /* For each block in the old chain (except the targetEUN of course),
399 free it and make it available for future use */ 399 free it and make it available for future use */
400 while (thisEUN <= nftl->lastEUN && thisEUN != targetEUN) { 400 while (thisEUN <= nftl->lastEUN && thisEUN != targetEUN) {
401 unsigned int EUNtmp; 401 unsigned int EUNtmp;
@@ -413,7 +413,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
413 } 413 }
414 thisEUN = EUNtmp; 414 thisEUN = EUNtmp;
415 } 415 }
416 416
417 /* Make this the new start of chain for thisVUC */ 417 /* Make this the new start of chain for thisVUC */
418 nftl->ReplUnitTable[targetEUN] = BLOCK_NIL; 418 nftl->ReplUnitTable[targetEUN] = BLOCK_NIL;
419 nftl->EUNtable[thisVUC] = targetEUN; 419 nftl->EUNtable[thisVUC] = targetEUN;
@@ -423,7 +423,7 @@ static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned p
423 423
424static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock) 424static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
425{ 425{
426 /* This is the part that needs some cleverness applied. 426 /* This is the part that needs some cleverness applied.
427 For now, I'm doing the minimum applicable to actually 427 For now, I'm doing the minimum applicable to actually
428 get the thing to work. 428 get the thing to work.
429 Wear-levelling and other clever stuff needs to be implemented 429 Wear-levelling and other clever stuff needs to be implemented
@@ -470,7 +470,7 @@ static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
470 return NFTL_foldchain (nftl, LongestChain, pendingblock); 470 return NFTL_foldchain (nftl, LongestChain, pendingblock);
471} 471}
472 472
473/* NFTL_findwriteunit: Return the unit number into which we can write 473/* NFTL_findwriteunit: Return the unit number into which we can write
474 for this block. Make it available if it isn't already 474 for this block. Make it available if it isn't already
475*/ 475*/
476static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block) 476static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
@@ -488,7 +488,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
488 a free space for the block in question. 488 a free space for the block in question.
489 */ 489 */
490 490
491 /* This condition catches the 0x[7f]fff cases, as well as 491 /* This condition catches the 0x[7f]fff cases, as well as
492 being a sanity check for past-end-of-media access 492 being a sanity check for past-end-of-media access
493 */ 493 */
494 lastEUN = BLOCK_NIL; 494 lastEUN = BLOCK_NIL;
@@ -503,7 +503,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
503 503
504 MTD_READOOB(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs, 504 MTD_READOOB(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs,
505 8, &retlen, (char *)&bci); 505 8, &retlen, (char *)&bci);
506 506
507 DEBUG(MTD_DEBUG_LEVEL2, "Status of block %d in EUN %d is %x\n", 507 DEBUG(MTD_DEBUG_LEVEL2, "Status of block %d in EUN %d is %x\n",
508 block , writeEUN, le16_to_cpu(bci.Status)); 508 block , writeEUN, le16_to_cpu(bci.Status));
509 509
@@ -518,10 +518,10 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
518 break; 518 break;
519 default: 519 default:
520 // Invalid block. Don't use it any more. Must implement. 520 // Invalid block. Don't use it any more. Must implement.
521 break; 521 break;
522 } 522 }
523 523
524 if (!silly--) { 524 if (!silly--) {
525 printk(KERN_WARNING 525 printk(KERN_WARNING
526 "Infinite loop in Virtual Unit Chain 0x%x\n", 526 "Infinite loop in Virtual Unit Chain 0x%x\n",
527 thisVUC); 527 thisVUC);
@@ -532,7 +532,7 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
532 writeEUN = nftl->ReplUnitTable[writeEUN]; 532 writeEUN = nftl->ReplUnitTable[writeEUN];
533 } 533 }
534 534
535 /* OK. We didn't find one in the existing chain, or there 535 /* OK. We didn't find one in the existing chain, or there
536 is no existing chain. */ 536 is no existing chain. */
537 537
538 /* Try to find an already-free block */ 538 /* Try to find an already-free block */
@@ -546,12 +546,12 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
546 546
547 /* First remember the start of this chain */ 547 /* First remember the start of this chain */
548 //u16 startEUN = nftl->EUNtable[thisVUC]; 548 //u16 startEUN = nftl->EUNtable[thisVUC];
549 549
550 //printk("Write to VirtualUnitChain %d, calling makefreeblock()\n", thisVUC); 550 //printk("Write to VirtualUnitChain %d, calling makefreeblock()\n", thisVUC);
551 writeEUN = NFTL_makefreeblock(nftl, 0xffff); 551 writeEUN = NFTL_makefreeblock(nftl, 0xffff);
552 552
553 if (writeEUN == BLOCK_NIL) { 553 if (writeEUN == BLOCK_NIL) {
554 /* OK, we accept that the above comment is 554 /* OK, we accept that the above comment is
555 lying - there may have been free blocks 555 lying - there may have been free blocks
556 last time we called NFTL_findfreeblock(), 556 last time we called NFTL_findfreeblock(),
557 but they are reserved for when we're 557 but they are reserved for when we're
@@ -562,21 +562,21 @@ static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
562 } 562 }
563 if (writeEUN == BLOCK_NIL) { 563 if (writeEUN == BLOCK_NIL) {
564 /* Ouch. This should never happen - we should 564 /* Ouch. This should never happen - we should
565 always be able to make some room somehow. 565 always be able to make some room somehow.
566 If we get here, we've allocated more storage 566 If we get here, we've allocated more storage
567 space than actual media, or our makefreeblock 567 space than actual media, or our makefreeblock
568 routine is missing something. 568 routine is missing something.
569 */ 569 */
570 printk(KERN_WARNING "Cannot make free space.\n"); 570 printk(KERN_WARNING "Cannot make free space.\n");
571 return BLOCK_NIL; 571 return BLOCK_NIL;
572 } 572 }
573 //printk("Restarting scan\n"); 573 //printk("Restarting scan\n");
574 lastEUN = BLOCK_NIL; 574 lastEUN = BLOCK_NIL;
575 continue; 575 continue;
576 } 576 }
577 577
578 /* We've found a free block. Insert it into the chain. */ 578 /* We've found a free block. Insert it into the chain. */
579 579
580 if (lastEUN != BLOCK_NIL) { 580 if (lastEUN != BLOCK_NIL) {
581 thisVUC |= 0x8000; /* It's a replacement block */ 581 thisVUC |= 0x8000; /* It's a replacement block */
582 } else { 582 } else {
@@ -749,7 +749,7 @@ extern char nftlmountrev[];
749 749
750static int __init init_nftl(void) 750static int __init init_nftl(void)
751{ 751{
752 printk(KERN_INFO "NFTL driver: nftlcore.c $Revision: 1.97 $, nftlmount.c %s\n", nftlmountrev); 752 printk(KERN_INFO "NFTL driver: nftlcore.c $Revision: 1.98 $, nftlmount.c %s\n", nftlmountrev);
753 753
754 return register_mtd_blktrans(&nftl_tr); 754 return register_mtd_blktrans(&nftl_tr);
755} 755}