ARM-Linux驱动--MTD驱动分析(三)
时间:11-20
来源:互联网
点击:
- stats=part->master->ts=part->master->ecc_ts;
- if(from>=mtd->size)
- len=0;
- elseif(from+len>mtd->size)
- len=mtd->size-from;
- res=part->master->read(part->master,from+part->offset,
- len,retlen,buf);
- if(unlikely(res)){
- if(res==-EUCLEAN)
- mtd->ecc_stats.corrected+=part->master->ecc_stats.corrected-stats.corrected;
- if(res==-EBADMSG)
- mtd->ecc_stats.failed+=part->master->ecc_stats.failed-stats.failed;
- }
- returnres;
- }
- staticintpart_point(structmtd_info*mtd,loff_tfrom,size_tlen,
- size_t*retlen,void**virt,resource_size_t*phys)
- {
- structmtd_part*part=PART(mtd);
- if(from>=mtd->size)
- len=0;
- elseif(from+len>mtd->size)
- len=mtd->size-from;
- returnpart->master->point(part->master,from+part->offset,
- len,retlen,virt,phys);
- }
- staticvoidpart_unpoint(structmtd_info*mtd,loff_tfrom,size_tlen)
- {
- structmtd_part*part=PART(mtd);
- part->master->unpoint(part->master,from+part->offset,len);
- }
- //获取空闲的内存驱动
- staticunsignedlongpart_get_unmapped_area(structmtd_info*mtd,
- unsignedlonglen,
- unsignedlongoffset,
- unsignedlongflags)
- {
- structmtd_part*part=PART(mtd);
- offset+=part->offset;
- returnpart->master->get_unmapped_area(part->master,len,offset,
- flags);
- }
- staticintpart_read_oob(structmtd_info*mtd,loff_tfrom,
- structmtd_oob_ops*ops)
- {
- structmtd_part*part=PART(mtd);
- intres;
- if(from>=mtd->size)
- return-EINVAL;
- if(ops->datbuf&&from+ops->len>mtd->size)
- return-EINVAL;
- res=part->master->read_oob(part->master,from+part->offset,ops);
- if(unlikely(res)){
- if(res==-EUCLEAN)
- mtd->ecc_stats.corrected++;
- if(res==-EBADMSG)
- mtd->ecc_stats.failed++;
- }
- returnres;
- }
- staticintpart_read_user_prot_reg(structmtd_info*mtd,loff_tfrom,
- size_tlen,size_t*retlen,u_char*buf)
- {
- structmtd_part*part=PART(mtd);
- returnpart->master->read_user_prot_reg(part->master,from,
- len,retlen,buf);
- }
- staticintpart_get_user_prot_info(structmtd_info*mtd,
- structotp_info*buf,size_tlen)
- {
- structmtd_part*part=PART(mtd);
- returnpart->master->get_user_prot_info(part->master,buf,len);
- }
- staticintpart_read_fact_prot_reg(structmtd_info*mtd,loff_tfrom,
- size_tlen,size_t*retlen,u_char*buf)
- {
- structmtd_part*part=PART(mtd);
- returnpart->master->read_fact_prot_reg(part->master,from,
- len,retlen,buf);
- }
- staticintpart_get_fact_prot_info(structmtd_info*mtd,structotp_info*buf,
- size_tlen)
- {
- structmtd_part*part=PART(mtd);
- returnpart->master->get_fact_prot_info(part->master,buf,len);
- }
- //分区写函数
- staticintpart_write(structmtd_info*mtd,loff_tto,size_tlen,
- size_t*retlen,constu_char*buf)
- {
- structmtd_part*part=PART(mtd);
- if(!(mtd->flags&MTD_WRITEABLE))
- return-EROFS;
- if(to>=mtd->size)
- len=0;
- elseif(to+len>mtd->size)
- len=mtd->size-to;
- returnpart->master->write(part->master,to+part->offset,
- len,retlen,buf);
- }
- staticintpart_panic_write(structmtd_info*mtd,loff_tto,size_tlen,
- size_t*retlen,constu_char*buf)
- {
- structmtd_part*part=PART(mtd);
- if(!(mtd->flags&MTD_WRITEABLE))
- return-EROFS;
- if(to>=mtd->size)
- len=0;
- elseif(to+len>mtd->size)
- len=mtd->size-to;
- returnpart->master->panic_write(part->master,to+part->offset,
- len,retlen,buf);
- }
- staticintpart_write_oob(structmtd_info*mtd,loff_tto,
- structmtd_oob_ops*ops)
- {
- structmtd_part*part=PART(mtd);
- if(!(mtd->flags&MTD_WRITEABLE))
- return-EROFS;
- if(to>=mtd->size)
- return-EINVAL;
- if(ops->datbuf&&to+ops->len>mtd->size)
- return-EINVAL;
- returnpart->master->write_oob(part->master,to+part->offset,ops);
- }
- staticintpart_write_user_prot_reg(structmtd_info*mtd,loff_tfrom,
- size_tlen,size_t*retlen,u_char*buf)
- {
- structmtd_part*part=PART(mtd);
- returnpart->master->write_user_prot_reg(part->master,from,
- len,retlen,buf);
- }
- staticintpart_lock_user_prot_reg(structmtd_info*mtd,loff_tfrom,
- size_tlen)
- {
- structmtd_part*part=PART(mtd);
- returnpart->master->lock_user_prot_reg(part->master,from,len);
- }
- staticintpart_writev(structmtd_info*mtd,conststructkvec*vecs,
- unsignedlongcount,loff_tto,size_t*retlen)
- {
- structm
上一篇: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)