nftl 37 drivers/mtd/nftlcore.c struct NFTLrecord *nftl; nftl 48 drivers/mtd/nftlcore.c nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL); nftl 50 drivers/mtd/nftlcore.c if (!nftl) nftl 53 drivers/mtd/nftlcore.c nftl->mbd.mtd = mtd; nftl 54 drivers/mtd/nftlcore.c nftl->mbd.devnum = -1; nftl 56 drivers/mtd/nftlcore.c nftl->mbd.tr = tr; nftl 58 drivers/mtd/nftlcore.c if (NFTL_mount(nftl) < 0) { nftl 60 drivers/mtd/nftlcore.c kfree(nftl); nftl 67 drivers/mtd/nftlcore.c nftl->cylinders = 1024; nftl 68 drivers/mtd/nftlcore.c nftl->heads = 16; nftl 70 drivers/mtd/nftlcore.c temp = nftl->cylinders * nftl->heads; nftl 71 drivers/mtd/nftlcore.c nftl->sectors = nftl->mbd.size / temp; nftl 72 drivers/mtd/nftlcore.c if (nftl->mbd.size % temp) { nftl 73 drivers/mtd/nftlcore.c nftl->sectors++; nftl 74 drivers/mtd/nftlcore.c temp = nftl->cylinders * nftl->sectors; nftl 75 drivers/mtd/nftlcore.c nftl->heads = nftl->mbd.size / temp; nftl 77 drivers/mtd/nftlcore.c if (nftl->mbd.size % temp) { nftl 78 drivers/mtd/nftlcore.c nftl->heads++; nftl 79 drivers/mtd/nftlcore.c temp = nftl->heads * nftl->sectors; nftl 80 drivers/mtd/nftlcore.c nftl->cylinders = nftl->mbd.size / temp; nftl 84 drivers/mtd/nftlcore.c if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) { nftl 90 drivers/mtd/nftlcore.c "match size of 0x%lx.\n", nftl->mbd.size); nftl 93 drivers/mtd/nftlcore.c nftl->cylinders, nftl->heads , nftl->sectors, nftl 94 drivers/mtd/nftlcore.c (long)nftl->cylinders * (long)nftl->heads * nftl 95 drivers/mtd/nftlcore.c (long)nftl->sectors ); nftl 98 drivers/mtd/nftlcore.c if (add_mtd_blktrans_dev(&nftl->mbd)) { nftl 99 drivers/mtd/nftlcore.c kfree(nftl->ReplUnitTable); nftl 100 drivers/mtd/nftlcore.c kfree(nftl->EUNtable); nftl 101 drivers/mtd/nftlcore.c kfree(nftl); nftl 105 drivers/mtd/nftlcore.c printk(KERN_INFO "NFTL: Found new nftl%c\n", nftl->mbd.devnum + 'a'); nftl 111 drivers/mtd/nftlcore.c struct NFTLrecord *nftl = (void *)dev; nftl 116 drivers/mtd/nftlcore.c kfree(nftl->ReplUnitTable); nftl 117 drivers/mtd/nftlcore.c kfree(nftl->EUNtable); nftl 190 drivers/mtd/nftlcore.c static u16 NFTL_findfreeblock(struct NFTLrecord *nftl, int desperate ) nftl 196 drivers/mtd/nftlcore.c u16 pot = nftl->LastFreeEUN; nftl 197 drivers/mtd/nftlcore.c int silly = nftl->nb_blocks; nftl 200 drivers/mtd/nftlcore.c if (!desperate && nftl->numfreeEUNs < 2) { nftl 207 drivers/mtd/nftlcore.c if (nftl->ReplUnitTable[pot] == BLOCK_FREE) { nftl 208 drivers/mtd/nftlcore.c nftl->LastFreeEUN = pot; nftl 209 drivers/mtd/nftlcore.c nftl->numfreeEUNs--; nftl 217 drivers/mtd/nftlcore.c if (++pot > nftl->lastEUN) nftl 218 drivers/mtd/nftlcore.c pot = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN); nftl 222 drivers/mtd/nftlcore.c "FirstEUN = %d\n", nftl->LastFreeEUN, nftl 223 drivers/mtd/nftlcore.c le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)); nftl 226 drivers/mtd/nftlcore.c } while (pot != nftl->LastFreeEUN); nftl 231 drivers/mtd/nftlcore.c static u16 NFTL_foldchain (struct NFTLrecord *nftl, unsigned thisVUC, unsigned pendingblock ) nftl 233 drivers/mtd/nftlcore.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 248 drivers/mtd/nftlcore.c thisEUN = nftl->EUNtable[thisVUC]; nftl 261 drivers/mtd/nftlcore.c while (thisEUN <= nftl->lastEUN ) { nftl 265 drivers/mtd/nftlcore.c for (block = 0; block < nftl->EraseSize / 512; block ++) { nftl 266 drivers/mtd/nftlcore.c nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) + nftl 322 drivers/mtd/nftlcore.c thisEUN = nftl->ReplUnitTable[thisEUN]; nftl 333 drivers/mtd/nftlcore.c for (block = 0; block < nftl->EraseSize / 512 ; block++) { nftl 349 drivers/mtd/nftlcore.c if (pendingblock >= (thisVUC * (nftl->EraseSize / 512)) && nftl 350 drivers/mtd/nftlcore.c pendingblock < ((thisVUC + 1)* (nftl->EraseSize / 512)) && nftl 351 drivers/mtd/nftlcore.c BlockLastState[pendingblock - (thisVUC * (nftl->EraseSize / 512))] != nftl 363 drivers/mtd/nftlcore.c targetEUN = NFTL_findfreeblock(nftl, 1); nftl 382 drivers/mtd/nftlcore.c nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 2 * 512 + 8, nftl 391 drivers/mtd/nftlcore.c for (block = 0; block < nftl->EraseSize / 512 ; block++) { nftl 397 drivers/mtd/nftlcore.c (pendingblock == (thisVUC * (nftl->EraseSize / 512) + block))) { nftl 407 drivers/mtd/nftlcore.c (nftl->EraseSize * BlockMap[block]) + (block * 512), nftl 413 drivers/mtd/nftlcore.c (nftl->EraseSize * BlockMap[block]) + (block * 512), nftl 423 drivers/mtd/nftlcore.c nftl_write(nftl->mbd.mtd, (nftl->EraseSize * targetEUN) + nftl 431 drivers/mtd/nftlcore.c nftl_write_oob(mtd, (nftl->EraseSize * targetEUN) + 8, nftl 441 drivers/mtd/nftlcore.c thisEUN = nftl->EUNtable[thisVUC]; nftl 446 drivers/mtd/nftlcore.c while (thisEUN <= nftl->lastEUN && thisEUN != targetEUN) { nftl 449 drivers/mtd/nftlcore.c EUNtmp = nftl->ReplUnitTable[thisEUN]; nftl 451 drivers/mtd/nftlcore.c if (NFTL_formatblock(nftl, thisEUN) < 0) { nftl 454 drivers/mtd/nftlcore.c nftl->ReplUnitTable[thisEUN] = BLOCK_RESERVED; nftl 457 drivers/mtd/nftlcore.c nftl->ReplUnitTable[thisEUN] = BLOCK_FREE; nftl 458 drivers/mtd/nftlcore.c nftl->numfreeEUNs++; nftl 464 drivers/mtd/nftlcore.c nftl->ReplUnitTable[targetEUN] = BLOCK_NIL; nftl 465 drivers/mtd/nftlcore.c nftl->EUNtable[thisVUC] = targetEUN; nftl 470 drivers/mtd/nftlcore.c static u16 NFTL_makefreeblock( struct NFTLrecord *nftl , unsigned pendingblock) nftl 483 drivers/mtd/nftlcore.c for (chain = 0; chain < le32_to_cpu(nftl->MediaHdr.FormattedSize) / nftl->EraseSize; chain++) { nftl 484 drivers/mtd/nftlcore.c EUN = nftl->EUNtable[chain]; nftl 487 drivers/mtd/nftlcore.c while (EUN <= nftl->lastEUN) { nftl 490 drivers/mtd/nftlcore.c EUN = nftl->ReplUnitTable[EUN] & 0x7fff; nftl 516 drivers/mtd/nftlcore.c return NFTL_foldchain (nftl, LongestChain, pendingblock); nftl 522 drivers/mtd/nftlcore.c static inline u16 NFTL_findwriteunit(struct NFTLrecord *nftl, unsigned block) nftl 525 drivers/mtd/nftlcore.c u16 thisVUC = block / (nftl->EraseSize / 512); nftl 526 drivers/mtd/nftlcore.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 528 drivers/mtd/nftlcore.c unsigned long blockofs = (block * 512) & (nftl->EraseSize -1); nftl 542 drivers/mtd/nftlcore.c writeEUN = nftl->EUNtable[thisVUC]; nftl 544 drivers/mtd/nftlcore.c while (writeEUN <= nftl->lastEUN) { nftl 552 drivers/mtd/nftlcore.c (writeEUN * nftl->EraseSize) + blockofs, nftl 580 drivers/mtd/nftlcore.c writeEUN = nftl->ReplUnitTable[writeEUN]; nftl 587 drivers/mtd/nftlcore.c writeEUN = NFTL_findfreeblock(nftl, 0); nftl 599 drivers/mtd/nftlcore.c writeEUN = NFTL_makefreeblock(nftl, BLOCK_NIL); nftl 609 drivers/mtd/nftlcore.c writeEUN = NFTL_findfreeblock(nftl, 1); nftl 632 drivers/mtd/nftlcore.c nftl->EUNtable[thisVUC] = writeEUN; nftl 637 drivers/mtd/nftlcore.c nftl->ReplUnitTable[writeEUN] = BLOCK_NIL; nftl 640 drivers/mtd/nftlcore.c nftl_read_oob(mtd, writeEUN * nftl->EraseSize + 8, 8, nftl 645 drivers/mtd/nftlcore.c nftl_write_oob(mtd, writeEUN * nftl->EraseSize + 8, 8, nftl 653 drivers/mtd/nftlcore.c nftl->ReplUnitTable[lastEUN] = writeEUN; nftl 655 drivers/mtd/nftlcore.c nftl_read_oob(mtd, (lastEUN * nftl->EraseSize) + 8, nftl 661 drivers/mtd/nftlcore.c nftl_write_oob(mtd, (lastEUN * nftl->EraseSize) + 8, nftl 677 drivers/mtd/nftlcore.c struct NFTLrecord *nftl = (void *)mbd; nftl 679 drivers/mtd/nftlcore.c unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1); nftl 683 drivers/mtd/nftlcore.c writeEUN = NFTL_findwriteunit(nftl, block); nftl 695 drivers/mtd/nftlcore.c nftl_write(nftl->mbd.mtd, (writeEUN * nftl->EraseSize) + blockofs, nftl 704 drivers/mtd/nftlcore.c struct NFTLrecord *nftl = (void *)mbd; nftl 705 drivers/mtd/nftlcore.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 707 drivers/mtd/nftlcore.c u16 thisEUN = nftl->EUNtable[block / (nftl->EraseSize / 512)]; nftl 708 drivers/mtd/nftlcore.c unsigned long blockofs = (block * 512) & (nftl->EraseSize - 1); nftl 717 drivers/mtd/nftlcore.c while (thisEUN < nftl->nb_blocks) { nftl 718 drivers/mtd/nftlcore.c if (nftl_read_oob(mtd, (thisEUN * nftl->EraseSize) + nftl 745 drivers/mtd/nftlcore.c block / (nftl->EraseSize / 512)); nftl 748 drivers/mtd/nftlcore.c thisEUN = nftl->ReplUnitTable[thisEUN]; nftl 757 drivers/mtd/nftlcore.c loff_t ptr = (lastgoodEUN * nftl->EraseSize) + blockofs; nftl 769 drivers/mtd/nftlcore.c struct NFTLrecord *nftl = (void *)dev; nftl 771 drivers/mtd/nftlcore.c geo->heads = nftl->heads; nftl 772 drivers/mtd/nftlcore.c geo->sectors = nftl->sectors; nftl 773 drivers/mtd/nftlcore.c geo->cylinders = nftl->cylinders; nftl 25 drivers/mtd/nftlmount.c static int find_boot_record(struct NFTLrecord *nftl) nftl 31 drivers/mtd/nftlmount.c struct NFTLMediaHeader *mh = &nftl->MediaHdr; nftl 32 drivers/mtd/nftlmount.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 41 drivers/mtd/nftlmount.c nftl->EraseSize = nftl->mbd.mtd->erasesize; nftl 42 drivers/mtd/nftlmount.c nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; nftl 44 drivers/mtd/nftlmount.c nftl->MediaUnit = BLOCK_NIL; nftl 45 drivers/mtd/nftlmount.c nftl->SpareMediaUnit = BLOCK_NIL; nftl 48 drivers/mtd/nftlmount.c for (block = 0; block < nftl->nb_blocks; block++) { nftl 53 drivers/mtd/nftlmount.c ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE, nftl 62 drivers/mtd/nftlmount.c block * nftl->EraseSize, nftl->mbd.mtd->index, ret); nftl 73 drivers/mtd/nftlmount.c block * nftl->EraseSize, nftl->mbd.mtd->index); nftl 79 drivers/mtd/nftlmount.c ret = nftl_read_oob(mtd, block * nftl->EraseSize + nftl 84 drivers/mtd/nftlmount.c block * nftl->EraseSize, nftl->mbd.mtd->index, ret); nftl 94 drivers/mtd/nftlmount.c block * nftl->EraseSize, nftl->mbd.mtd->index, nftl 100 drivers/mtd/nftlmount.c ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, nftl 104 drivers/mtd/nftlmount.c block * nftl->EraseSize, nftl->mbd.mtd->index, ret); nftl 111 drivers/mtd/nftlmount.c block * nftl->EraseSize, nftl->mbd.mtd->index); nftl 123 drivers/mtd/nftlmount.c nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize); nftl 132 drivers/mtd/nftlmount.c nftl->SpareMediaUnit = block; nftl 135 drivers/mtd/nftlmount.c nftl->ReplUnitTable[block] = BLOCK_RESERVED; nftl 159 drivers/mtd/nftlmount.c nftl->EraseSize = nftl->mbd.mtd->erasesize << (0xff - mh->UnitSizeFactor); nftl 160 drivers/mtd/nftlmount.c nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; nftl 163 drivers/mtd/nftlmount.c nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN); nftl 164 drivers/mtd/nftlmount.c if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) { nftl 167 drivers/mtd/nftlmount.c nftl->nb_boot_blocks, nftl->nb_blocks); nftl 171 drivers/mtd/nftlmount.c nftl->numvunits = le32_to_cpu(mh->FormattedSize) / nftl->EraseSize; nftl 172 drivers/mtd/nftlmount.c if (nftl->numvunits > (nftl->nb_blocks - nftl->nb_boot_blocks - 2)) { nftl 175 drivers/mtd/nftlmount.c nftl->numvunits, nftl->nb_blocks, nftl->nb_boot_blocks); nftl 179 drivers/mtd/nftlmount.c nftl->mbd.size = nftl->numvunits * (nftl->EraseSize / SECTORSIZE); nftl 183 drivers/mtd/nftlmount.c nftl->nb_blocks = le16_to_cpu(mh->NumEraseUnits) + le16_to_cpu(mh->FirstPhysicalEUN); nftl 186 drivers/mtd/nftlmount.c nftl->lastEUN = nftl->nb_blocks - 1; nftl 189 drivers/mtd/nftlmount.c nftl->EUNtable = kmalloc_array(nftl->nb_blocks, sizeof(u16), nftl 191 drivers/mtd/nftlmount.c if (!nftl->EUNtable) { nftl 196 drivers/mtd/nftlmount.c nftl->ReplUnitTable = kmalloc_array(nftl->nb_blocks, nftl 199 drivers/mtd/nftlmount.c if (!nftl->ReplUnitTable) { nftl 200 drivers/mtd/nftlmount.c kfree(nftl->EUNtable); nftl 206 drivers/mtd/nftlmount.c for (i = 0; i < nftl->nb_boot_blocks; i++) nftl 207 drivers/mtd/nftlmount.c nftl->ReplUnitTable[i] = BLOCK_RESERVED; nftl 209 drivers/mtd/nftlmount.c for (; i < nftl->nb_blocks; i++) { nftl 210 drivers/mtd/nftlmount.c nftl->ReplUnitTable[i] = BLOCK_NOTEXPLORED; nftl 214 drivers/mtd/nftlmount.c nftl->ReplUnitTable[block] = BLOCK_RESERVED; nftl 217 drivers/mtd/nftlmount.c for (i = 0; i < nftl->nb_blocks; i++) { nftl 222 drivers/mtd/nftlmount.c ret = mtd->read(nftl->mbd.mtd, nftl 223 drivers/mtd/nftlmount.c block * nftl->EraseSize + i + nftl 229 drivers/mtd/nftlmount.c kfree(nftl->ReplUnitTable); nftl 230 drivers/mtd/nftlmount.c kfree(nftl->EUNtable); nftl 236 drivers/mtd/nftlmount.c nftl->ReplUnitTable[i] = BLOCK_RESERVED; nftl 238 drivers/mtd/nftlmount.c if (mtd_block_isbad(nftl->mbd.mtd, nftl 239 drivers/mtd/nftlmount.c i * nftl->EraseSize)) nftl 240 drivers/mtd/nftlmount.c nftl->ReplUnitTable[i] = BLOCK_RESERVED; nftl 243 drivers/mtd/nftlmount.c nftl->MediaUnit = block; nftl 262 drivers/mtd/nftlmount.c static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int len, nftl 265 drivers/mtd/nftlmount.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 305 drivers/mtd/nftlmount.c int NFTL_formatblock(struct NFTLrecord *nftl, int block) nftl 310 drivers/mtd/nftlmount.c struct erase_info *instr = &nftl->instr; nftl 311 drivers/mtd/nftlmount.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 314 drivers/mtd/nftlmount.c if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, nftl 329 drivers/mtd/nftlmount.c instr->addr = block * nftl->EraseSize; nftl 330 drivers/mtd/nftlmount.c instr->len = nftl->EraseSize; nftl 348 drivers/mtd/nftlmount.c if (check_free_sectors(nftl, instr->addr, nftl->EraseSize, 1) != 0) nftl 352 drivers/mtd/nftlmount.c if (nftl_write_oob(mtd, block * nftl->EraseSize + SECTORSIZE + nftl 359 drivers/mtd/nftlmount.c mtd_block_markbad(nftl->mbd.mtd, instr->addr); nftl 372 drivers/mtd/nftlmount.c static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_block) nftl 374 drivers/mtd/nftlmount.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 380 drivers/mtd/nftlmount.c sectors_per_block = nftl->EraseSize / SECTORSIZE; nftl 385 drivers/mtd/nftlmount.c block * nftl->EraseSize + i * SECTORSIZE, nftl 396 drivers/mtd/nftlmount.c check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE, nftl 406 drivers/mtd/nftlmount.c nftl->EraseSize + nftl 417 drivers/mtd/nftlmount.c block = nftl->ReplUnitTable[block]; nftl 418 drivers/mtd/nftlmount.c if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) nftl 420 drivers/mtd/nftlmount.c if (block == BLOCK_NIL || block >= nftl->nb_blocks) nftl 426 drivers/mtd/nftlmount.c static int calc_chain_length(struct NFTLrecord *nftl, unsigned int first_block) nftl 434 drivers/mtd/nftlmount.c if (length >= nftl->nb_blocks) { nftl 439 drivers/mtd/nftlmount.c block = nftl->ReplUnitTable[block]; nftl 440 drivers/mtd/nftlmount.c if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) nftl 442 drivers/mtd/nftlmount.c if (block == BLOCK_NIL || block >= nftl->nb_blocks) nftl 458 drivers/mtd/nftlmount.c static void format_chain(struct NFTLrecord *nftl, unsigned int first_block) nftl 465 drivers/mtd/nftlmount.c block1 = nftl->ReplUnitTable[block]; nftl 468 drivers/mtd/nftlmount.c if (NFTL_formatblock(nftl, block) < 0) { nftl 470 drivers/mtd/nftlmount.c nftl->ReplUnitTable[block] = BLOCK_RESERVED; nftl 472 drivers/mtd/nftlmount.c nftl->ReplUnitTable[block] = BLOCK_FREE; nftl 478 drivers/mtd/nftlmount.c if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) nftl 480 drivers/mtd/nftlmount.c if (block == BLOCK_NIL || block >= nftl->nb_blocks) nftl 491 drivers/mtd/nftlmount.c static int check_and_mark_free_block(struct NFTLrecord *nftl, int block) nftl 493 drivers/mtd/nftlmount.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 499 drivers/mtd/nftlmount.c if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, nftl 507 drivers/mtd/nftlmount.c if (check_free_sectors (nftl, block * nftl->EraseSize, nftl->EraseSize, 1) != 0) nftl 515 drivers/mtd/nftlmount.c block * nftl->EraseSize + SECTORSIZE + 8, 8, nftl 521 drivers/mtd/nftlmount.c for (i = 0; i < nftl->EraseSize; i += SECTORSIZE) { nftl 523 drivers/mtd/nftlmount.c if (check_free_sectors (nftl, block * nftl->EraseSize + i, nftl 527 drivers/mtd/nftlmount.c if (nftl_read_oob(mtd, block * nftl->EraseSize + i, nftl 552 drivers/mtd/nftlmount.c static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block) nftl 554 drivers/mtd/nftlmount.c struct mtd_info *mtd = nftl->mbd.mtd; nftl 558 drivers/mtd/nftlmount.c if (nftl_read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8,