Lines Matching defs:nftl

25 #include <linux/mtd/nftl.h>
37 struct NFTLrecord *nftl;
48 nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
50 if (!nftl)
53 nftl->mbd.mtd = mtd;
54 nftl->mbd.devnum = -1;
56 nftl->mbd.tr = tr;
58 if (NFTL_mount(nftl) < 0) {
60 kfree(nftl);
67 nftl->cylinders = 1024;
68 nftl->heads = 16;
70 temp = nftl->cylinders * nftl->heads;
71 nftl->sectors = nftl->mbd.size / temp;
72 if (nftl->mbd.size % temp) {
73 nftl->sectors++;
74 temp = nftl->cylinders * nftl->sectors;
75 nftl->heads = nftl->mbd.size / temp;
77 if (nftl->mbd.size % temp) {
78 nftl->heads++;
79 temp = nftl->heads * nftl->sectors;
80 nftl->cylinders = nftl->mbd.size / temp;
84 if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) {
90 "match size of 0x%lx.\n", nftl->mbd.size);
93 nftl->cylinders, nftl->heads , nftl->sectors,
94 (long)nftl->cylinders * (long)nftl->heads *
95 (long)nftl->sectors );
98 if (add_mtd_blktrans_dev(&nftl->mbd)) {
99 kfree(nftl->ReplUnitTable);
100 kfree(nftl->EUNtable);
101 kfree(nftl);
105 printk(KERN_INFO "NFTL: Found new nftl%c\n", nftl->mbd.devnum + 'a');
111 struct NFTLrecord *nftl = (void *)dev;
116 kfree(nftl->ReplUnitTable);
117 kfree(nftl->EUNtable);
190 static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate )
196 u16 pot = nftl->LastFreeEUN;
197 int silly = nftl->nb_blocks;
200 if (!desperate && nftl->numfreeEUNs < 2) {
207 if (nftl->ReplUnitTable[pot] == BLOCK_FREE) {
208 nftl->LastFreeEUN = pot;
209 nftl->numfreeEUNs--;
217 if (++pot > nftl->lastEUN)
218 pot = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN);
222 "FirstEUN = %d\n", nftl->LastFreeEUN,
223 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN));
226 } while (pot != nftl->LastFreeEUN);
231 static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned pendingblock )
233 struct mtd_info *mtd = nftl->mbd.mtd;
248 thisEUN = nftl->EUNtable[thisVUC];
261 while (thisEUN <= nftl->lastEUN ) {
265 for (block = 0; block < nftl->EraseSize / 512; block ++) {
266 nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) +
322 thisEUN = nftl->ReplUnitTable[thisEUN];
333 for (block = 0; block < nftl->EraseSize / 512 ; block++) {
349 if (pendingblock >= (thisVUC * (nftl->EraseSize / 512)) &&
350 pendingblock < ((thisVUC + 1)* (nftl->EraseSize / 512)) &&
351 BlockLastState[pendingblock - (thisVUC * (nftl->EraseSize / 512))] !=
363 targetEUN = NFTL_findfreeblock(nftl, 1);
382 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8,
391 for (block = 0; block < nftl->EraseSize / 512 ; block++) {
397 (pendingblock == (thisVUC * (nftl->EraseSize / 512) + block))) {
407 (nftl->EraseSize * BlockMap[block]) + (block * 512),
413 (nftl->EraseSize * BlockMap[block]) + (block * 512),
423 nftl_write(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) +
431 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 8,
441 thisEUN = nftl->EUNtable[thisVUC];
446 while (thisEUN <= nftl->lastEUN && thisEUN != targetEUN) {
449 EUNtmp = nftl->ReplUnitTable[thisEUN];
451 if (NFTL_formatblock(nftl, thisEUN) < 0) {
454 nftl->ReplUnitTable[thisEUN] = BLOCK_RESERVED;
457 nftl->ReplUnitTable[thisEUN] = BLOCK_FREE;
458 nftl->numfreeEUNs++;
464 nftl->ReplUnitTable[targetEUN] = BLOCK_NIL;
465 nftl->EUNtable[thisVUC] = targetEUN;
470 static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
483 for (chain = 0; chain < le32_to_cpu(nftl->MediaHdr.FormattedSize) / nftl->EraseSize; chain++) {
484 EUN = nftl->EUNtable[chain];
487 while (EUN <= nftl->lastEUN) {
490 EUN = nftl->ReplUnitTable[EUN] & 0x7fff;
516 return NFTL_foldchain (nftl, LongestChain, pendingblock);
522 static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
525 u16 thisVUC = block / (nftl->EraseSize / 512);
526 struct mtd_info *mtd = nftl->mbd.mtd;
528 unsigned long blockofs = (block * 512) & (nftl->EraseSize -1);
542 writeEUN = nftl->EUNtable[thisVUC];
544 while (writeEUN <= nftl->lastEUN) {
552 (writeEUN * nftl->EraseSize) + blockofs,
580 writeEUN = nftl->ReplUnitTable[writeEUN];
587 writeEUN = NFTL_findfreeblock(nftl, 0);
596 //u16 startEUN = nftl->EUNtable[thisVUC];
599 writeEUN = NFTL_makefreeblock(nftl, BLOCK_NIL);
609 writeEUN = NFTL_findfreeblock(nftl, 1);
631 nftl->EUNtable[thisVUC] = writeEUN;
636 nftl->ReplUnitTable[writeEUN] = BLOCK_NIL;
639 nftl_read_oob(mtd, writeEUN * nftl->EraseSize + 8, 8,
644 nftl_write_oob(mtd, writeEUN * nftl->EraseSize + 8, 8,
652 nftl->ReplUnitTable[lastEUN] = writeEUN;
654 nftl_read_oob(mtd, (lastEUN * nftl->EraseSize) + 8,
660 nftl_write_oob(mtd, (lastEUN * nftl->EraseSize) + 8,
676 struct NFTLrecord *nftl = (void *)mbd;
678 unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1);
682 writeEUN = NFTL_findwriteunit(nftl, block);
694 nftl_write(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs,
703 struct NFTLrecord *nftl = (void *)mbd;
704 struct mtd_info *mtd = nftl->mbd.mtd;
706 u16 thisEUN = nftl->EUNtable[block / (nftl->EraseSize / 512)];
707 unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1);
716 while (thisEUN < nftl->nb_blocks) {
717 if (nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) +
744 block / (nftl->EraseSize / 512));
747 thisEUN = nftl->ReplUnitTable[thisEUN];
756 loff_t ptr = (lastgoodEUN * nftl->EraseSize) + blockofs;
768 struct NFTLrecord *nftl = (void *)dev;
770 geo->heads = nftl->heads;
771 geo->sectors = nftl->sectors;
772 geo->cylinders = nftl->cylinders;
785 .name = "nftl",