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->nb_blocks * sizeof(u16));
269 inftl->VUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16),
271 if (!inftl->VUtable) {
272 kfree(inftl->PUtable);
275 inftl->nb_blocks * sizeof(u16));
280 for (i = 0; i < inftl->nb_boot_blocks; i++)
281 inftl->PUtable[i] = BLOCK_RESERVED;
283 for (; i < inftl->nb_blocks; i++)
284 inftl->PUtable[i] = BLOCK_NOTEXPLORED;
287 inftl->PUtable[block] = BLOCK_RESERVED;
290 for (i = 0; i < inftl->nb_blocks; i++) {
294 for (physblock = 0; physblock < inftl->EraseSize; physblock += inftl->mbd.mtd->erasesize) {
295 if (mtd_block_isbad(inftl->mbd.mtd,
296 i * inftl->EraseSize + physblock))
297 inftl->PUtable[i] = BLOCK_RESERVED;
301 inftl->MediaUnit = block;
323 static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
326 struct mtd_info *mtd = inftl->mbd.mtd;
368 int INFTL_formatblock(struct INFTLrecord *inftl, int block)
372 struct erase_info *instr = &inftl->instr;
373 struct mtd_info *mtd = inftl->mbd.mtd;
376 pr_debug("INFTL: INFTL_formatblock(inftl=%p,block=%d)\n", inftl, block);
384 instr->addr = block * inftl->EraseSize;
385 instr->len = inftl->mbd.mtd->erasesize;
389 for (physblock = 0; physblock < inftl->EraseSize;
393 ret = mtd_erase(inftl->mbd.mtd, instr);
405 if (check_free_sectors(inftl, instr->addr, instr->len, 1) != 0)
415 instr->addr = block * inftl->EraseSize + SECTORSIZE * 2;
422 mtd_block_markbad(inftl->mbd.mtd, instr->addr);
434 static void format_chain(struct INFTLrecord *inftl, unsigned int first_block)
442 block1 = inftl->PUtable[block];
445 if (INFTL_formatblock(inftl, block) < 0) {
449 inftl->PUtable[block] = BLOCK_RESERVED;
451 inftl->PUtable[block] = BLOCK_FREE;
457 if (block == BLOCK_NIL || block >= inftl->lastEUN)
545 pr_debug("INFTL: INFTL_mount(inftl=%p)\n", s);