Lines Matching refs:mtd
58 struct mtd_info *mtd; member
94 static void alloc_bbt(struct mtd_info *mtd, unsigned int *bbt) in alloc_bbt() argument
97 apanic_erase_blocks = (mtd->size)>>(mtd->erasesize_shift); in alloc_bbt()
104 static void scan_bbt(struct mtd_info *mtd, unsigned int *bbt) in scan_bbt() argument
109 if (mtd->block_isbad(mtd, i*mtd->erasesize)) in scan_bbt()
116 static unsigned int phy_offset(struct mtd_info *mtd, unsigned int offset) in phy_offset() argument
118 unsigned int logic_block = offset>>(mtd->erasesize_shift); in phy_offset()
132 return offset + ((phy_block-logic_block)<<mtd->erasesize_shift); in phy_offset()
178 if (count > ctx->mtd->writesize) in apanic_proc_read()
179 count = ctx->mtd->writesize; in apanic_proc_read()
181 page_no = (file_offset + offset) / ctx->mtd->writesize; in apanic_proc_read()
182 page_offset = (file_offset + offset) % ctx->mtd->writesize; in apanic_proc_read()
185 if (phy_offset(ctx->mtd, (page_no * ctx->mtd->writesize)) in apanic_proc_read()
191 rc = ctx->mtd->read(ctx->mtd, in apanic_proc_read()
192 phy_offset(ctx->mtd, (page_no * ctx->mtd->writesize)), in apanic_proc_read()
193 ctx->mtd->writesize, in apanic_proc_read()
218 erase.mtd = ctx->mtd; in mtd_panic_erase()
220 erase.len = ctx->mtd->erasesize; in mtd_panic_erase()
222 for (i = 0; i < ctx->mtd->size; i += ctx->mtd->erasesize) { in mtd_panic_erase()
227 if (get_bb(erase.addr>>ctx->mtd->erasesize_shift, apanic_bbt)) { in mtd_panic_erase()
236 rc = ctx->mtd->erase(ctx->mtd, &erase); in mtd_panic_erase()
245 if (ctx->mtd->block_markbad(ctx->mtd, in mtd_panic_erase()
254 set_bb(erase.addr>>ctx->mtd->erasesize_shift, in mtd_panic_erase()
294 static void mtd_panic_notify_add(struct mtd_info *mtd) in mtd_panic_notify_add() argument
302 if (strcmp(mtd->name, CONFIG_APANIC_PLABEL)) in mtd_panic_notify_add()
305 ctx->mtd = mtd; in mtd_panic_notify_add()
307 alloc_bbt(mtd, apanic_bbt); in mtd_panic_notify_add()
308 scan_bbt(mtd, apanic_bbt); in mtd_panic_notify_add()
315 rc = mtd->read(mtd, phy_offset(mtd, 0), mtd->writesize, in mtd_panic_notify_add()
325 if (len != mtd->writesize) { in mtd_panic_notify_add()
330 printk(KERN_INFO "apanic: Bound to mtd partition '%s'\n", mtd->name); in mtd_panic_notify_add()
386 ctx->mtd = NULL; in mtd_panic_notify_add()
389 static void mtd_panic_notify_remove(struct mtd_info *mtd) in mtd_panic_notify_remove() argument
392 if (mtd == ctx->mtd) { in mtd_panic_notify_remove()
393 ctx->mtd = NULL; in mtd_panic_notify_remove()
394 printk(KERN_INFO "apanic: Unbound from %s\n", mtd->name); in mtd_panic_notify_remove()
405 static int apanic_writeflashpage(struct mtd_info *mtd, loff_t to, in apanic_writeflashpage() argument
412 if (panic && !mtd->panic_write) { in apanic_writeflashpage()
415 } else if (!panic && !mtd->write) { in apanic_writeflashpage()
420 to = phy_offset(mtd, to); in apanic_writeflashpage()
427 rc = mtd->panic_write(mtd, to, mtd->writesize, &wlen, buf); in apanic_writeflashpage()
429 rc = mtd->write(mtd, to, mtd->writesize, &wlen, buf); in apanic_writeflashpage()
448 static int apanic_write_console(struct mtd_info *mtd, unsigned int off) in apanic_write_console() argument
459 rc = log_buf_copy(ctx->bounce, idx, mtd->writesize); in apanic_write_console()
463 if (rc != mtd->writesize) in apanic_write_console()
469 if (rc != mtd->writesize) in apanic_write_console()
470 memset(ctx->bounce + rc, 0, mtd->writesize - rc); in apanic_write_console()
472 rc2 = apanic_writeflashpage(mtd, off, ctx->bounce); in apanic_write_console()
507 if (!ctx->mtd) in apanic()
514 console_offset = ctx->mtd->writesize; in apanic()
519 console_len = apanic_write_console(ctx->mtd, console_offset); in apanic()
530 ctx->mtd->writesize); in apanic()
532 threads_offset = ctx->mtd->writesize; in apanic()
538 threads_len = apanic_write_console(ctx->mtd, threads_offset); in apanic()
558 rc = apanic_writeflashpage(ctx->mtd, 0, ctx->bounce); in apanic()