请教一个关于flash_eraseall的问题
对于NAND Flash类型的记忆体,网上资料都说在erase的动作中会把bad block给标记出来。对此我研究了flash_eraseall的代码,企图找到mark bad block是如何实现的。后来发现flash_eraseall其实仅对NANDFlash做了ioctl(fd, MEMGETBADBLOCK, &offset),ioctl(fd, MEMERASE, &erase) 两个动作,并没有做检测并且mark bad block。于是我怀疑这个动作内嵌在MEMERASE或者MEMGETBADBLOCK之中了,我就又找到mtd_ioctl.c,看到:******************************
case MEMERASE:
{
struct erase_info *erase;
if(!(file->f_mode & 2))
return -EPERM;
erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL);
if (!erase)
ret = -ENOMEM;
else {
wait_queue_head_t waitq;
DECLARE_WAITQUEUE(wait, current);
init_waitqueue_head(&waitq);
memset (erase,0,sizeof(struct erase_info));
if (copy_from_user(&erase->addr, argp,
sizeof(struct erase_info_user))) {
kfree(erase);
return -EFAULT;
}
erase->mtd = mtd;
erase->callback = mtdchar_erase_callback;
erase->priv = (unsigned long)&waitq;
/*
FIXME: Allow INTERRUPTIBLE. Which means
not having the wait_queue head on the stack.
If the wq_head is on the stack, and we
leave because we got interrupted, then the
wq_head is no longer there when the
callback routine tries to wake us up.
*/
ret = mtd->erase(mtd, erase);
if (!ret) {
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&waitq, &wait);
if (erase->state != MTD_ERASE_DONE &&
erase->state != MTD_ERASE_FAILED)
schedule();
remove_wait_queue(&waitq, &wait);
set_current_state(TASK_RUNNING);
ret = (erase->state == MTD_ERASE_FAILED)?-EIO:0;
}
kfree(erase);
}
break;
}
******************************
case MEMGETBADBLOCK:
{
loff_t offs;
if (copy_from_user(&offs, argp, sizeof(loff_t)))
return -EFAULT;
if (!mtd->block_isbad)
ret = -EOPNOTSUPP;
else
return mtd->block_isbad(mtd, offs);
break;
}
貌似也没有看到我希望的mark bad block的过程,所以想在此请教大家,为何我在erase NANDFlash的全过程看不到标记坏块的动作,是否真的不存在?那么NANDFlash是如何标记在使用过程中产生的坏块的?
页:
[1]