ARM-Linux驱动--MTD驱动分析(三)
时间:11-20
来源:互联网
点击:
- td_part*part=PART(mtd);
- if(!(mtd->flags&MTD_WRITEABLE))
- return-EROFS;
- returnpart->master->writev(part->master,vecs,count,
- to+part->offset,retlen);
- }
- staticintpart_erase(structmtd_info*mtd,structerase_info*instr)
- {
- structmtd_part*part=PART(mtd);
- intret;
- if(!(mtd->flags&MTD_WRITEABLE))
- return-EROFS;
- if(instr->addr>=mtd->size)
- return-EINVAL;
- instr->addr+=part->offset;
- ret=part->master->erase(part->master,instr);
- if(ret){
- if(instr->fail_addr!=MTD_FAIL_ADDR_UNKNOWN)
- instr->fail_addr-=part->offset;
- instr->addr-=part->offset;
- }
- returnret;
- }
- voidmtd_erase_callback(structerase_info*instr)
- {
- if(instr->mtd->erase==part_erase){
- structmtd_part*part=PART(instr->mtd);
- if(instr->fail_addr!=MTD_FAIL_ADDR_UNKNOWN)
- instr->fail_addr-=part->offset;
- instr->addr-=part->offset;
- }
- if(instr->callback)
- instr->callback(instr);
- }
- EXPORT_SYMBOL_GPL(mtd_erase_callback);
- staticintpart_lock(structmtd_info*mtd,loff_tofs,uint64_tlen)
- {
- structmtd_part*part=PART(mtd);
- if((len+ofs)>mtd->size)
- return-EINVAL;
- returnpart->master->lock(part->master,ofs+part->offset,len);
- }
- staticintpart_unlock(structmtd_info*mtd,loff_tofs,uint64_tlen)
- {
- structmtd_part*part=PART(mtd);
- if((len+ofs)>mtd->size)
- return-EINVAL;
- returnpart->master->unlock(part->master,ofs+part->offset,len);
- }
- //分区同步函数
- staticvoidpart_sync(structmtd_info*mtd)
- {
- structmtd_part*part=PART(mtd);
- part->master->sync(part->master);
- }
- //支持电源管理的功能函数
- staticintpart_suspend(structmtd_info*mtd)
- {
- structmtd_part*part=PART(mtd);
- returnpart->master->suspend(part->master);
- }
- staticvoidpart_resume(structmtd_info*mtd)
- {
- structmtd_part*part=PART(mtd);
- part->master->resume(part->master);
- }
- staticintpart_block_isbad(structmtd_info*mtd,loff_tofs)
- {
- structmtd_part*part=PART(mtd);
- if(ofs>=mtd->size)
- return-EINVAL;
- ofs+=part->offset;
- returnpart->master->block_isbad(part->master,ofs);
- }
- //标记设备地址坏块
- staticintpart_block_markbad(structmtd_info*mtd,loff_tofs)
- {
- structmtd_part*part=PART(mtd);
- intres;
- if(!(mtd->flags&MTD_WRITEABLE))
- return-EROFS;
- if(ofs>=mtd->size)
- return-EINVAL;
- ofs+=part->offset;
- res=part->master->block_markbad(part->master,ofs);
- if(!res)
- mtd->ecc_stats.badblocks++;
- returnres;
- }
下篇分析具体的MTD设备,字符设备和块设备,待续........
上一篇:ARM-Linux驱动--DM9000网卡驱动分析(四)
下一篇:ARM-Linux移植攻略--yaffs2 Partially written block xxx detected 问题解决
下一篇:ARM-Linux移植攻略--yaffs2 Partially written block xxx detected 问题解决
ARM-Linux驱动MTD驱动分 相关文章:
- ARM-Linux驱动--MTD驱动分析(一)(11-20)
- ARM-Linux驱动--MTD驱动分析(二)(11-20)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)