• 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

29 #include <linux/mtd/nftl.h>
36 * is used for management of Erase Unit in other routines in nftl.c and nftlmount.c
38 static int find_boot_record(struct NFTLrecord *nftl)
44 struct NFTLMediaHeader *mh = &nftl->MediaHdr;
45 struct mtd_info *mtd = nftl->mbd.mtd;
53 nftl->EraseSize if there were any point in doing so. */
54 nftl->EraseSize = nftl->mbd.mtd->erasesize;
55 nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize;
57 nftl->MediaUnit = BLOCK_NIL;
58 nftl->SpareMediaUnit = BLOCK_NIL;
61 for (block = 0; block < nftl->nb_blocks; block++) {
66 ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE,
75 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
88 if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize +
92 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
102 block * nftl->EraseSize, nftl->mbd.mtd->index,
108 if ((ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE,
111 block * nftl->EraseSize, nftl->mbd.mtd->index, ret);
118 block * nftl->EraseSize, nftl->mbd.mtd->index);
131 nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize);
140 nftl->SpareMediaUnit = block;
143 nftl->ReplUnitTable[block] = BLOCK_RESERVED;
154 nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN);
155 if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) {
158 nftl->nb_boot_blocks, nftl->nb_blocks);
162 nftl->numvunits = le32_to_cpu(mh->FormattedSize) / nftl->EraseSize;
163 if (nftl->numvunits > (nftl->nb_blocks - nftl->nb_boot_blocks - 2)) {
166 nftl->numvunits, nftl->nb_blocks, nftl->nb_boot_blocks);
170 nftl->mbd.size = nftl->numvunits * (nftl->EraseSize / SECTORSIZE);
174 nftl->nb_blocks = le16_to_cpu(mh->NumEraseUnits) + le16_to_cpu(mh->FirstPhysicalEUN);
176 nftl->lastEUN = nftl->nb_blocks - 1;
179 nftl->EUNtable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL);
180 if (!nftl->EUNtable) {
185 nftl->ReplUnitTable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL);
186 if (!nftl->ReplUnitTable) {
187 kfree(nftl->EUNtable);
193 for (i = 0; i < nftl->nb_boot_blocks; i++)
194 nftl->ReplUnitTable[i] = BLOCK_RESERVED;
196 for (; i < nftl->nb_blocks; i++) {
197 nftl->ReplUnitTable[i] = BLOCK_NOTEXPLORED;
201 nftl->ReplUnitTable[block] = BLOCK_RESERVED;
204 for (i = 0; i < nftl->nb_blocks; i++) {
205 if (nftl->mbd.mtd->block_isbad(nftl->mbd.mtd, i * nftl->EraseSize))
206 nftl->ReplUnitTable[i] = BLOCK_RESERVED;
209 nftl->MediaUnit = block;
228 static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int len,
231 u8 buf[SECTORSIZE + nftl->mbd.mtd->oobsize];
232 struct mtd_info *mtd = nftl->mbd.mtd;
262 int NFTL_formatblock(struct NFTLrecord *nftl, int block)
267 struct erase_info *instr = &nftl->instr;
268 struct mtd_info *mtd = nftl->mbd.mtd;
271 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8,
285 instr->mtd = nftl->mbd.mtd;
286 instr->addr = block * nftl->EraseSize;
287 instr->len = nftl->EraseSize;
303 if (check_free_sectors(nftl, instr->addr, nftl->EraseSize, 1) != 0)
307 if (nftl_write_oob(mtd, block * nftl->EraseSize + SECTORSIZE +
314 nftl->mbd.mtd->block_markbad(nftl->mbd.mtd, instr->addr);
327 static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_block)
329 struct mtd_info *mtd = nftl->mbd.mtd;
335 sectors_per_block = nftl->EraseSize / SECTORSIZE;
340 block * nftl->EraseSize + i * SECTORSIZE,
351 check_free_sectors(nftl, block * nftl->EraseSize + i * SECTORSIZE,
361 nftl->EraseSize +
372 block = nftl->ReplUnitTable[block];
373 if (!(block == BLOCK_NIL || block < nftl->nb_blocks))
375 if (block == BLOCK_NIL || block >= nftl->nb_blocks)
381 static int calc_chain_length(struct NFTLrecord *nftl, unsigned int first_block)
389 if (length >= nftl->nb_blocks) {
390 printk("nftl: length too long %d !\n", length);
394 block = nftl->ReplUnitTable[block];
395 if (!(block == BLOCK_NIL || block < nftl->nb_blocks))
397 if (block == BLOCK_NIL || block >= nftl->nb_blocks)
403 static void format_chain(struct NFTLrecord *nftl, unsigned int first_block)
410 block1 = nftl->ReplUnitTable[block];
413 if (NFTL_formatblock(nftl, block) < 0) {
415 nftl->ReplUnitTable[block] = BLOCK_RESERVED;
417 nftl->ReplUnitTable[block] = BLOCK_FREE;
423 if (!(block == BLOCK_NIL || block < nftl->nb_blocks))
425 if (block == BLOCK_NIL || block >= nftl->nb_blocks)
436 static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)
438 struct mtd_info *mtd = nftl->mbd.mtd;
444 if (nftl_read_oob(mtd, block * nftl->EraseSize + SECTORSIZE + 8, 8,
452 if (check_free_sectors (nftl, block * nftl->EraseSize, nftl->EraseSize, 1) != 0)
460 block * nftl->EraseSize + SECTORSIZE + 8, 8,
476 static int get_fold_mark(struct NFTLrecord *nftl, unsigned int block)
478 struct mtd_info *mtd = nftl->mbd.mtd;
482 if (nftl_read_oob(mtd, block * nftl->EraseSize + 2 * SECTORSIZE + 8,