static struct file_system_typejffs2_fs_type = {
.owner= THIS_MODULE,
.name= "jffs2",
.get_sb= jffs2_get_sb,
.kill_sb= jffs2_kill_sb,
};
jffs2_get_sb()
------get_sb_mtd()
------struct mtd_info *mtd;
mtd = get_mtd_device(NULL, mtdnr);
------- ret = mtd_table[i]
return ret;
返回的mtd最后被赋值给:jffs2_sb_info *c;
c->mtd =sb->s_mtd;
static int s3c24xx_nand_probe(struct platform_device *pdev,
enum s3c_cpu_type cpu_type)
{
………………
s3c2410_nand_init_chip(info,nmtd, sets);
nmtd->scan_res= nand_scan_ident(&nmtd->mtd,
(sets) ? sets->nr_chips : 1);
if(nmtd->scan_res == 0) {
s3c2410_nand_update_chip(info, nmtd);
nand_scan_tail(&nmtd->mtd);
s3c2410_nand_add_partition(info, nmtd,sets);
}
……………….
}
int nand_scan_tail(struct mtd_info *mtd)
{
………………..
mtd->type = MTD_NANDFLASH;
mtd->flags= MTD_CAP_NANDFLASH;
mtd->erase= nand_erase;
mtd->point= NULL;
mtd->unpoint= NULL;
mtd->read= nand_read;
mtd->write= nand_write;
mtd->read_oob= nand_read_oob;
mtd->write_oob= nand_write_oob;
mtd->sync= nand_sync;
mtd->lock= NULL;
mtd->unlock= NULL;
mtd->suspend= nand_suspend;
mtd->resume= nand_resume;
mtd->block_isbad= nand_block_isbad;
mtd->block_markbad= nand_block_markbad;
………………….
}
static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
struct s3c2410_nand_mtd *mtd,
struct s3c2410_nand_set *set)
{
…………………..
returnadd_mtd_device(&mtd->mtd);
…………………..
}
int add_mtd_device(struct mtd_info *mtd)
{
……………….
mtd_table[i]= mtd;
……………….
}