aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/inftlcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/inftlcore.c')
-rw-r--r--drivers/mtd/inftlcore.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index 39eb53f6551f..8db8618c18d2 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * inftlcore.c -- Linux driver for Inverse Flash Translation Layer (INFTL) 2 * inftlcore.c -- Linux driver for Inverse Flash Translation Layer (INFTL)
3 * 3 *
4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com) 4 * (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
@@ -7,7 +7,7 @@
7 * (c) 1999 Machine Vision Holdings, Inc. 7 * (c) 1999 Machine Vision Holdings, Inc.
8 * Author: David Woodhouse <dwmw2@infradead.org> 8 * Author: David Woodhouse <dwmw2@infradead.org>
9 * 9 *
10 * $Id: inftlcore.c,v 1.18 2004/11/16 18:28:59 dwmw2 Exp $ 10 * $Id: inftlcore.c,v 1.19 2005/11/07 11:14:20 gleixner Exp $
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
@@ -113,14 +113,14 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
113 113
114 if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) { 114 if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) {
115 /* 115 /*
116 Oh no we don't have 116 Oh no we don't have
117 mbd.size == heads * cylinders * sectors 117 mbd.size == heads * cylinders * sectors
118 */ 118 */
119 printk(KERN_WARNING "INFTL: cannot calculate a geometry to " 119 printk(KERN_WARNING "INFTL: cannot calculate a geometry to "
120 "match size of 0x%lx.\n", inftl->mbd.size); 120 "match size of 0x%lx.\n", inftl->mbd.size);
121 printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d " 121 printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d "
122 "(== 0x%lx sects)\n", 122 "(== 0x%lx sects)\n",
123 inftl->cylinders, inftl->heads , inftl->sectors, 123 inftl->cylinders, inftl->heads , inftl->sectors,
124 (long)inftl->cylinders * (long)inftl->heads * 124 (long)inftl->cylinders * (long)inftl->heads *
125 (long)inftl->sectors ); 125 (long)inftl->sectors );
126 } 126 }
@@ -223,7 +223,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
223 "Virtual Unit Chain %d!\n", thisVUC); 223 "Virtual Unit Chain %d!\n", thisVUC);
224 return BLOCK_NIL; 224 return BLOCK_NIL;
225 } 225 }
226 226
227 /* 227 /*
228 * Scan to find the Erase Unit which holds the actual data for each 228 * Scan to find the Erase Unit which holds the actual data for each
229 * 512-byte block within the Chain. 229 * 512-byte block within the Chain.
@@ -264,7 +264,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
264 "Unit Chain 0x%x\n", thisVUC); 264 "Unit Chain 0x%x\n", thisVUC);
265 return BLOCK_NIL; 265 return BLOCK_NIL;
266 } 266 }
267 267
268 thisEUN = inftl->PUtable[thisEUN]; 268 thisEUN = inftl->PUtable[thisEUN];
269 } 269 }
270 270
@@ -295,15 +295,15 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
295 */ 295 */
296 if (BlockMap[block] == BLOCK_NIL) 296 if (BlockMap[block] == BLOCK_NIL)
297 continue; 297 continue;
298 298
299 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * 299 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize *
300 BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE, 300 BlockMap[block]) + (block * SECTORSIZE), SECTORSIZE,
301 &retlen, movebuf); 301 &retlen, movebuf);
302 if (ret < 0) { 302 if (ret < 0) {
303 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize * 303 ret = MTD_READ(inftl->mbd.mtd, (inftl->EraseSize *
304 BlockMap[block]) + (block * SECTORSIZE), 304 BlockMap[block]) + (block * SECTORSIZE),
305 SECTORSIZE, &retlen, movebuf); 305 SECTORSIZE, &retlen, movebuf);
306 if (ret != -EIO) 306 if (ret != -EIO)
307 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went " 307 DEBUG(MTD_DEBUG_LEVEL1, "INFTL: error went "
308 "away on retry?\n"); 308 "away on retry?\n");
309 } 309 }
@@ -355,7 +355,7 @@ static u16 INFTL_foldchain(struct INFTLrecord *inftl, unsigned thisVUC, unsigned
355static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock) 355static u16 INFTL_makefreeblock(struct INFTLrecord *inftl, unsigned pendingblock)
356{ 356{
357 /* 357 /*
358 * This is the part that needs some cleverness applied. 358 * This is the part that needs some cleverness applied.
359 * For now, I'm doing the minimum applicable to actually 359 * For now, I'm doing the minimum applicable to actually
360 * get the thing to work. 360 * get the thing to work.
361 * Wear-levelling and other clever stuff needs to be implemented 361 * Wear-levelling and other clever stuff needs to be implemented
@@ -414,7 +414,7 @@ static int nrbits(unsigned int val, int bitcount)
414} 414}
415 415
416/* 416/*
417 * INFTL_findwriteunit: Return the unit number into which we can write 417 * INFTL_findwriteunit: Return the unit number into which we can write
418 * for this block. Make it available if it isn't already. 418 * for this block. Make it available if it isn't already.
419 */ 419 */
420static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block) 420static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
@@ -463,10 +463,10 @@ static inline u16 INFTL_findwriteunit(struct INFTLrecord *inftl, unsigned block)
463 * Invalid block. Don't use it any more. 463 * Invalid block. Don't use it any more.
464 * Must implement. 464 * Must implement.
465 */ 465 */
466 break; 466 break;
467 } 467 }
468 468
469 if (!silly--) { 469 if (!silly--) {
470 printk(KERN_WARNING "INFTL: infinite loop in " 470 printk(KERN_WARNING "INFTL: infinite loop in "
471 "Virtual Unit Chain 0x%x\n", thisVUC); 471 "Virtual Unit Chain 0x%x\n", thisVUC);
472 return 0xffff; 472 return 0xffff;
@@ -482,7 +482,7 @@ hitused:
482 482
483 483
484 /* 484 /*
485 * OK. We didn't find one in the existing chain, or there 485 * OK. We didn't find one in the existing chain, or there
486 * is no existing chain. Allocate a new one. 486 * is no existing chain. Allocate a new one.
487 */ 487 */
488 writeEUN = INFTL_findfreeblock(inftl, 0); 488 writeEUN = INFTL_findfreeblock(inftl, 0);
@@ -506,8 +506,8 @@ hitused:
506 if (writeEUN == BLOCK_NIL) { 506 if (writeEUN == BLOCK_NIL) {
507 /* 507 /*
508 * Ouch. This should never happen - we should 508 * Ouch. This should never happen - we should
509 * always be able to make some room somehow. 509 * always be able to make some room somehow.
510 * If we get here, we've allocated more storage 510 * If we get here, we've allocated more storage
511 * space than actual media, or our makefreeblock 511 * space than actual media, or our makefreeblock
512 * routine is missing something. 512 * routine is missing something.
513 */ 513 */
@@ -518,7 +518,7 @@ hitused:
518 INFTL_dumpVUchains(inftl); 518 INFTL_dumpVUchains(inftl);
519#endif 519#endif
520 return BLOCK_NIL; 520 return BLOCK_NIL;
521 } 521 }
522 } 522 }
523 523
524 /* 524 /*
@@ -543,7 +543,7 @@ hitused:
543 parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0; 543 parity |= (nrbits(prev_block, 16) & 0x1) ? 0x2 : 0;
544 parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0; 544 parity |= (nrbits(anac, 8) & 0x1) ? 0x4 : 0;
545 parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0; 545 parity |= (nrbits(nacs, 8) & 0x1) ? 0x8 : 0;
546 546
547 oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC); 547 oob.u.a.virtualUnitNo = cpu_to_le16(thisVUC);
548 oob.u.a.prevUnitNo = cpu_to_le16(prev_block); 548 oob.u.a.prevUnitNo = cpu_to_le16(prev_block);
549 oob.u.a.ANAC = anac; 549 oob.u.a.ANAC = anac;
@@ -562,7 +562,7 @@ hitused:
562 oob.u.b.parityPerField = parity; 562 oob.u.b.parityPerField = parity;
563 oob.u.b.discarded = 0xaa; 563 oob.u.b.discarded = 0xaa;
564 564
565 MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize + 565 MTD_WRITEOOB(inftl->mbd.mtd, writeEUN * inftl->EraseSize +
566 SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u); 566 SECTORSIZE * 4 + 8, 8, &retlen, (char *)&oob.u);
567 567
568 inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC]; 568 inftl->PUtable[writeEUN] = inftl->VUtable[thisVUC];
@@ -602,7 +602,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
602 "Virtual Unit Chain %d!\n", thisVUC); 602 "Virtual Unit Chain %d!\n", thisVUC);
603 return; 603 return;
604 } 604 }
605 605
606 /* 606 /*
607 * Scan through the Erase Units to determine whether any data is in 607 * Scan through the Erase Units to determine whether any data is in
608 * each of the 512-byte blocks within the Chain. 608 * each of the 512-byte blocks within the Chain.
@@ -642,7 +642,7 @@ static void INFTL_trydeletechain(struct INFTLrecord *inftl, unsigned thisVUC)
642 "Unit Chain 0x%x\n", thisVUC); 642 "Unit Chain 0x%x\n", thisVUC);
643 return; 643 return;
644 } 644 }
645 645
646 thisEUN = inftl->PUtable[thisEUN]; 646 thisEUN = inftl->PUtable[thisEUN];
647 } 647 }
648 648
@@ -758,7 +758,7 @@ foundit:
758 return 0; 758 return 0;
759} 759}
760 760
761static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block, 761static int inftl_writeblock(struct mtd_blktrans_dev *mbd, unsigned long block,
762 char *buffer) 762 char *buffer)
763{ 763{
764 struct INFTLrecord *inftl = (void *)mbd; 764 struct INFTLrecord *inftl = (void *)mbd;
@@ -893,7 +893,7 @@ extern char inftlmountrev[];
893 893
894static int __init init_inftl(void) 894static int __init init_inftl(void)
895{ 895{
896 printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.18 $, " 896 printk(KERN_INFO "INFTL: inftlcore.c $Revision: 1.19 $, "
897 "inftlmount.c %s\n", inftlmountrev); 897 "inftlmount.c %s\n", inftlmountrev);
898 898
899 return register_mtd_blktrans(&inftl_tr); 899 return register_mtd_blktrans(&inftl_tr);