• Home
  • Raw
  • Download

Lines Matching refs:nftl

25 static int find_boot_record(struct NFTLrecord *nftl)  in find_boot_record()  argument
31 struct NFTLMediaHeader *mh = &nftl->MediaHdr; in find_boot_record()
32 struct mtd_info *mtd = nftl->mbd.mtd; in find_boot_record()
41 nftl->EraseSize = nftl->mbd.mtd->erasesize; in find_boot_record()
42 nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; in find_boot_record()
44 nftl->MediaUnit = BLOCK_NIL; in find_boot_record()
45 nftl->SpareMediaUnit = BLOCK_NIL; in find_boot_record()
48 for (block = 0; block < nftl->nb_blocks; block++) { in find_boot_record()
53 ret = mtd_read(mtd, block * nftl->EraseSize, SECTORSIZE, in find_boot_record()
62 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
73 block * nftl->EraseSize, nftl->mbd.mtd->index); in find_boot_record()
79 ret = nftl_read_oob(mtd, block * nftl->EraseSize + in find_boot_record()
84 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
94 block * nftl->EraseSize, nftl->mbd.mtd->index, in find_boot_record()
100 ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, in find_boot_record()
104 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); in find_boot_record()
111 block * nftl->EraseSize, nftl->mbd.mtd->index); in find_boot_record()
123 nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize); in find_boot_record()
132 nftl->SpareMediaUnit = block; in find_boot_record()
135 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in find_boot_record()
159 nftl->EraseSize = nftl->mbd.mtd->erasesize << (0xff - mh->UnitSizeFactor); in find_boot_record()
160 nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize; in find_boot_record()
163 nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN); in find_boot_record()
164 if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) { in find_boot_record()
167 nftl->nb_boot_blocks, nftl->nb_blocks); in find_boot_record()
171 nftl->numvunits = le32_to_cpu(mh->FormattedSize) / nftl->EraseSize; in find_boot_record()
172 if (nftl->numvunits > (nftl->nb_blocks - nftl->nb_boot_blocks - 2)) { in find_boot_record()
175 nftl->numvunits, nftl->nb_blocks, nftl->nb_boot_blocks); in find_boot_record()
179 nftl->mbd.size = nftl->numvunits * (nftl->EraseSize / SECTORSIZE); in find_boot_record()
183 nftl->nb_blocks = le16_to_cpu(mh->NumEraseUnits) + le16_to_cpu(mh->FirstPhysicalEUN); in find_boot_record()
186 nftl->lastEUN = nftl->nb_blocks - 1; in find_boot_record()
189 nftl->EUNtable = kmalloc_array(nftl->nb_blocks, sizeof(u16), in find_boot_record()
191 if (!nftl->EUNtable) { in find_boot_record()
196 nftl->ReplUnitTable = kmalloc_array(nftl->nb_blocks, in find_boot_record()
199 if (!nftl->ReplUnitTable) { in find_boot_record()
200 kfree(nftl->EUNtable); in find_boot_record()
206 for (i = 0; i < nftl->nb_boot_blocks; i++) in find_boot_record()
207 nftl->ReplUnitTable[i] = BLOCK_RESERVED; in find_boot_record()
209 for (; i < nftl->nb_blocks; i++) { in find_boot_record()
210 nftl->ReplUnitTable[i] = BLOCK_NOTEXPLORED; in find_boot_record()
214 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in find_boot_record()
217 for (i = 0; i < nftl->nb_blocks; i++) { in find_boot_record()
222 ret = mtd->read(nftl->mbd.mtd, in find_boot_record()
223 block * nftl->EraseSize + i + in find_boot_record()
229 kfree(nftl->ReplUnitTable); in find_boot_record()
230 kfree(nftl->EUNtable); in find_boot_record()
236 nftl->ReplUnitTable[i] = BLOCK_RESERVED; in find_boot_record()
238 if (mtd_block_isbad(nftl->mbd.mtd, in find_boot_record()
239 i * nftl->EraseSize)) in find_boot_record()
240 nftl->ReplUnitTable[i] = BLOCK_RESERVED; in find_boot_record()
243 nftl->MediaUnit = block; in find_boot_record()
262 static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int len, in check_free_sectors() argument
265 struct mtd_info *mtd = nftl->mbd.mtd; in check_free_sectors()
305 int NFTL_formatblock(struct NFTLrecord *nftl, int block) in NFTL_formatblock() argument
310 struct erase_info *instr = &nftl->instr; in NFTL_formatblock()
311 struct mtd_info *mtd = nftl->mbd.mtd; in NFTL_formatblock()
314 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, in NFTL_formatblock()
329 instr->addr = block * nftl->EraseSize; in NFTL_formatblock()
330 instr->len = nftl->EraseSize; in NFTL_formatblock()
348 if (check_free_sectors(nftl, instr->addr, nftl->EraseSize, 1) != 0) in NFTL_formatblock()
352 if (nftl_write_oob(mtd, block * nftl->EraseSize + SECTORSIZE + in NFTL_formatblock()
359 mtd_block_markbad(nftl->mbd.mtd, instr->addr); in NFTL_formatblock()
372 static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_block) in check_sectors_in_chain() argument
374 struct mtd_info *mtd = nftl->mbd.mtd; in check_sectors_in_chain()
380 sectors_per_block = nftl->EraseSize / SECTORSIZE; in check_sectors_in_chain()
385 block * nftl->EraseSize + i * SECTORSIZE, in check_sectors_in_chain()
396 check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE, in check_sectors_in_chain()
406 nftl->EraseSize + in check_sectors_in_chain()
417 block = nftl->ReplUnitTable[block]; in check_sectors_in_chain()
418 if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) in check_sectors_in_chain()
420 if (block == BLOCK_NIL || block >= nftl->nb_blocks) in check_sectors_in_chain()
426 static int calc_chain_length(struct NFTLrecord *nftl, unsigned int first_block) in calc_chain_length() argument
434 if (length >= nftl->nb_blocks) { in calc_chain_length()
439 block = nftl->ReplUnitTable[block]; in calc_chain_length()
440 if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) in calc_chain_length()
442 if (block == BLOCK_NIL || block >= nftl->nb_blocks) in calc_chain_length()
458 static void format_chain(struct NFTLrecord *nftl, unsigned int first_block) in format_chain() argument
465 block1 = nftl->ReplUnitTable[block]; in format_chain()
468 if (NFTL_formatblock(nftl, block) < 0) { in format_chain()
470 nftl->ReplUnitTable[block] = BLOCK_RESERVED; in format_chain()
472 nftl->ReplUnitTable[block] = BLOCK_FREE; in format_chain()
478 if (!(block == BLOCK_NIL || block < nftl->nb_blocks)) in format_chain()
480 if (block == BLOCK_NIL || block >= nftl->nb_blocks) in format_chain()
491 static int check_and_mark_free_block(struct NFTLrecord *nftl, int block) in check_and_mark_free_block() argument
493 struct mtd_info *mtd = nftl->mbd.mtd; in check_and_mark_free_block()
499 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8, in check_and_mark_free_block()
507 if (check_free_sectors (nftl, block * nftl->EraseSize, nftl->EraseSize, 1) != 0) in check_and_mark_free_block()
515 block * nftl->EraseSize + SECTORSIZE + 8, 8, in check_and_mark_free_block()
521 for (i = 0; i < nftl->EraseSize; i += SECTORSIZE) { in check_and_mark_free_block()
523 if (check_free_sectors (nftl, block * nftl->EraseSize + i, in check_and_mark_free_block()
527 if (nftl_read_oob(mtd, block * nftl->EraseSize + i, in check_and_mark_free_block()
552 static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block) in get_fold_mark() argument
554 struct mtd_info *mtd = nftl->mbd.mtd; in get_fold_mark()
558 if (nftl_read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8, in get_fold_mark()