• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/mtd/

Lines Matching refs:nftl

38 #include <linux/mtd/nftl.h>
50 struct NFTLrecord *nftl;
68 nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
70 if (!nftl) {
75 nftl->mbd.mtd = mtd;
76 nftl->mbd.devnum = -1;
78 nftl->mbd.tr = tr;
80 if (NFTL_mount(nftl) < 0) {
82 kfree(nftl);
89 nftl->cylinders = 1024;
90 nftl->heads = 16;
92 temp = nftl->cylinders * nftl->heads;
93 nftl->sectors = nftl->mbd.size / temp;
94 if (nftl->mbd.size % temp) {
95 nftl->sectors++;
96 temp = nftl->cylinders * nftl->sectors;
97 nftl->heads = nftl->mbd.size / temp;
99 if (nftl->mbd.size % temp) {
100 nftl->heads++;
101 temp = nftl->heads * nftl->sectors;
102 nftl->cylinders = nftl->mbd.size / temp;
106 if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) {
112 "match size of 0x%lx.\n", nftl->mbd.size);
115 nftl->cylinders, nftl->heads , nftl->sectors,
116 (long)nftl->cylinders * (long)nftl->heads *
117 (long)nftl->sectors );
120 if (add_mtd_blktrans_dev(&nftl->mbd)) {
121 kfree(nftl->ReplUnitTable);
122 kfree(nftl->EUNtable);
123 kfree(nftl);
127 printk(KERN_INFO "NFTL: Found new nftl%c\n", nftl->mbd.devnum + 'a');
133 struct NFTLrecord *nftl = (void *)dev;
138 kfree(nftl->ReplUnitTable);
139 kfree(nftl->EUNtable);
212 static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate )
218 u16 pot = nftl->LastFreeEUN;
219 int silly = nftl->nb_blocks;
222 if (!desperate && nftl->numfreeEUNs < 2) {
229 if (nftl->ReplUnitTable[pot] == BLOCK_FREE) {
230 nftl->LastFreeEUN = pot;
231 nftl->numfreeEUNs--;
239 if (++pot > nftl->lastEUN)
240 pot = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN);
244 "FirstEUN = %d\n", nftl->LastFreeEUN,
245 le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN));
248 } while (pot != nftl->LastFreeEUN);
253 static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned pendingblock )
255 struct mtd_info *mtd = nftl->mbd.mtd;
270 thisEUN = nftl->EUNtable[thisVUC];
283 while (thisEUN <= nftl->lastEUN ) {
287 for (block = 0; block < nftl->EraseSize / 512; block ++) {
288 nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) +
345 thisEUN = nftl->ReplUnitTable[thisEUN];
356 for (block = 0; block < nftl->EraseSize / 512 ; block++) {
372 if (pendingblock >= (thisVUC * (nftl->EraseSize / 512)) &&
373 pendingblock < ((thisVUC + 1)* (nftl->EraseSize / 512)) &&
374 BlockLastState[pendingblock - (thisVUC * (nftl->EraseSize / 512))] !=
386 targetEUN = NFTL_findfreeblock(nftl, 1);
405 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8,
414 for (block = 0; block < nftl->EraseSize / 512 ; block++) {
420 (pendingblock == (thisVUC * (nftl->EraseSize / 512) + block))) {
429 ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block]) + (block * 512),
432 ret = mtd->read(mtd, (nftl->EraseSize * BlockMap[block])
441 nftl_write(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) +
449 nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 8,
459 thisEUN = nftl->EUNtable[thisVUC];
464 while (thisEUN <= nftl->lastEUN && thisEUN != targetEUN) {
467 EUNtmp = nftl->ReplUnitTable[thisEUN];
469 if (NFTL_formatblock(nftl, thisEUN) < 0) {
472 nftl->ReplUnitTable[thisEUN] = BLOCK_RESERVED;
475 nftl->ReplUnitTable[thisEUN] = BLOCK_FREE;
476 nftl->numfreeEUNs++;
482 nftl->ReplUnitTable[targetEUN] = BLOCK_NIL;
483 nftl->EUNtable[thisVUC] = targetEUN;
488 static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock)
501 for (chain = 0; chain < le32_to_cpu(nftl->MediaHdr.FormattedSize) / nftl->EraseSize; chain++) {
502 EUN = nftl->EUNtable[chain];
505 while (EUN <= nftl->lastEUN) {
508 EUN = nftl->ReplUnitTable[EUN] & 0x7fff;
534 return NFTL_foldchain (nftl, LongestChain, pendingblock);
540 static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block)
543 u16 thisVUC = block / (nftl->EraseSize / 512);
544 struct mtd_info *mtd = nftl->mbd.mtd;
546 unsigned long blockofs = (block * 512) & (nftl->EraseSize -1);
560 writeEUN = nftl->EUNtable[thisVUC];
562 while (writeEUN <= nftl->lastEUN) {
570 (writeEUN * nftl->EraseSize) + blockofs,
598 writeEUN = nftl->ReplUnitTable[writeEUN];
605 writeEUN = NFTL_findfreeblock(nftl, 0);
614 //u16 startEUN = nftl->EUNtable[thisVUC];
617 writeEUN = NFTL_makefreeblock(nftl, BLOCK_NIL);
627 writeEUN = NFTL_findfreeblock(nftl, 1);
650 nftl->EUNtable[thisVUC] = writeEUN;
655 nftl->ReplUnitTable[writeEUN] = BLOCK_NIL;
658 nftl_read_oob(mtd, writeEUN * nftl->EraseSize + 8, 8,
663 nftl_write_oob(mtd, writeEUN * nftl->EraseSize + 8, 8,
671 nftl->ReplUnitTable[lastEUN] = writeEUN;
673 nftl_read_oob(mtd, (lastEUN * nftl->EraseSize) + 8,
679 nftl_write_oob(mtd, (lastEUN * nftl->EraseSize) + 8,
695 struct NFTLrecord *nftl = (void *)mbd;
697 unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1);
701 writeEUN = NFTL_findwriteunit(nftl, block);
713 nftl_write(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs,
722 struct NFTLrecord *nftl = (void *)mbd;
723 struct mtd_info *mtd = nftl->mbd.mtd;
725 u16 thisEUN = nftl->EUNtable[block / (nftl->EraseSize / 512)];
726 unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1);
735 while (thisEUN < nftl->nb_blocks) {
736 if (nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) +
763 block / (nftl->EraseSize / 512));
766 thisEUN = nftl->ReplUnitTable[thisEUN];
775 loff_t ptr = (lastgoodEUN * nftl->EraseSize) + blockofs;
787 struct NFTLrecord *nftl = (void *)dev;
789 geo->heads = nftl->heads;
790 geo->sectors = nftl->sectors;
791 geo->cylinders = nftl->cylinders;
804 .name = "nftl",