Lines Matching refs:inftl
22 #include <linux/mtd/inftl.h>
31 static int find_boot_record(struct INFTLrecord *inftl)
37 struct INFTLMediaHeader *mh = &inftl->MediaHdr;
38 struct mtd_info *mtd = inftl->mbd.mtd;
42 pr_debug("INFTL: find_boot_record(inftl=%p)\n", inftl);
49 inftl->EraseSize = inftl->mbd.mtd->erasesize;
50 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
52 inftl->MediaUnit = BLOCK_NIL;
55 for (block = 0; block < inftl->nb_blocks; block++) {
62 ret = mtd_read(mtd, block * inftl->EraseSize, SECTORSIZE,
72 block * inftl->EraseSize,
73 inftl->mbd.mtd->index, ret);
89 block * inftl->EraseSize + SECTORSIZE + 8,
94 "(err %d)\n", block * inftl->EraseSize,
95 inftl->mbd.mtd->index, ret);
107 mtd_read(mtd, block * inftl->EraseSize + 4096, SECTORSIZE,
169 inftl->EraseSize = inftl->mbd.mtd->erasesize <<
171 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
196 struct erase_info *instr = &inftl->instr;
205 instr->addr = ip->Reserved0 * inftl->EraseSize;
206 instr->len = inftl->EraseSize;
236 inftl->nb_boot_blocks = ip->firstUnit;
237 inftl->numvunits = ip->virtualUnits;
238 if (inftl->numvunits > (inftl->nb_blocks -
239 inftl->nb_boot_blocks - 2)) {
243 inftl->numvunits, inftl->nb_blocks,
244 inftl->nb_boot_blocks);
248 inftl->mbd.size = inftl->numvunits *
249 (inftl->EraseSize / SECTORSIZE);
255 inftl->firstEUN = ip->firstUnit;
256 inftl->lastEUN = ip->lastUnit;
257 inftl->nb_blocks = ip->lastUnit + 1;
260 inftl->PUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16),
262 if (!inftl->PUtable)
265 inftl->VUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16),
267 if (!inftl->VUtable) {
268 kfree(inftl->PUtable);
273 for (i = 0; i < inftl->nb_boot_blocks; i++)
274 inftl->PUtable[i] = BLOCK_RESERVED;
276 for (; i < inftl->nb_blocks; i++)
277 inftl->PUtable[i] = BLOCK_NOTEXPLORED;
280 inftl->PUtable[block] = BLOCK_RESERVED;
283 for (i = 0; i < inftl->nb_blocks; i++) {
287 for (physblock = 0; physblock < inftl->EraseSize; physblock += inftl->mbd.mtd->erasesize) {
288 if (mtd_block_isbad(inftl->mbd.mtd,
289 i * inftl->EraseSize + physblock))
290 inftl->PUtable[i] = BLOCK_RESERVED;
294 inftl->MediaUnit = block;
316 static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
319 struct mtd_info *mtd = inftl->mbd.mtd;
361 int INFTL_formatblock(struct INFTLrecord *inftl, int block)
365 struct erase_info *instr = &inftl->instr;
366 struct mtd_info *mtd = inftl->mbd.mtd;
369 pr_debug("INFTL: INFTL_formatblock(inftl=%p,block=%d)\n", inftl, block);
377 instr->addr = block * inftl->EraseSize;
378 instr->len = inftl->mbd.mtd->erasesize;
382 for (physblock = 0; physblock < inftl->EraseSize;
386 ret = mtd_erase(inftl->mbd.mtd, instr);
398 if (check_free_sectors(inftl, instr->addr, instr->len, 1) != 0)
408 instr->addr = block * inftl->EraseSize + SECTORSIZE * 2;
415 mtd_block_markbad(inftl->mbd.mtd, instr->addr);
427 static void format_chain(struct INFTLrecord *inftl, unsigned int first_block)
435 block1 = inftl->PUtable[block];
438 if (INFTL_formatblock(inftl, block) < 0) {
442 inftl->PUtable[block] = BLOCK_RESERVED;
444 inftl->PUtable[block] = BLOCK_FREE;
450 if (block == BLOCK_NIL || block >= inftl->lastEUN)
538 pr_debug("INFTL: INFTL_mount(inftl=%p)\n", s);