Linux内核的Nand驱动流程分析
时间:11-28
来源:互联网
点击:
- (err!=0)
- gotoexit_error;
- sets=(plat!=NULL)?plat->sets:NULL;
- nr_sets=(plat!=NULL)?plat->nr_sets:1;
- info->mtd_count=nr_sets;
- /*allocateourinformation*/
- size=nr_sets*sizeof(*info->mtds);
- info->mtds=kzalloc(size,GFP_KERNEL);
- if(info->mtds==NULL){
- dev_err(&pdev->dev,"failedtoallocatemtdstorage");
- err=-ENOMEM;
- gotoexit_error;
- }
- /*initialiseallpossiblechips*/
- nmtd=info->mtds;
- for(setno=0;setno
- pr_debug("initialisingset%d(%p,info%p)",setno,nmtd,info);
- s3c2410_nand_init_chip(info,nmtd,sets);
- nmtd->scan_res=nand_scan_ident(&nmtd->mtd,
- (sets)?sets->nr_chips:1,
- NULL);
- if(nmtd->scan_res==0){
- s3c2410_nand_update_chip(info,nmtd);
- nand_scan_tail(&nmtd->mtd);
- s3c2410_nand_add_partition(info,nmtd,sets);
- }
- if(sets!=NULL)
- sets++;
- }
- err=s3c2410_nand_cpufreq_register(info);
- if(err<0){
- dev_err(&pdev->dev,"failedtoinitcpufreqsupport");
- gotoexit_error;
- }
- if(allow_clk_suspend(info)){
- dev_info(&pdev->dev,"clockidlesupportenabled");
- s3c2410_nand_clk_set_state(info,CLOCK_SUSPEND);
- }
- pr_debug("initialisedok");
- return0;
- exit_error:
- s3c24xx_nand_remove(pdev);
- if(err==0)
- err=-EINVAL;
- returnerr;
- }
- res=pdev->resource;
- size=resource_size(res);
- info->area=request_mem_region(res->start,size,pdev->name);
- if(info->area==NULL){
- dev_err(&pdev->dev,"cannotreserveregisterregion");
- err=-ENOENT;
- gotoexit_error;
- }
- info->regs=ioremap(res->start,size);
继续往下看代码,到for循环处停下来,我们需要注意一下这部分代码,因为我们看到了s3c2410_nand_init_chip,从函数名称上很容易可以看出,这就是Nand的初始化代码,但是这里为什么要使用一个for循环呢?我们看到循环控制变量是nr_sets,往上可以找到
- sets=(plat!=NULL)?plat->sets:NULL;
- nr_sets=(plat!=NULL)?plat->nr_sets:1;
- structs3c2410_platform_nand*plat=to_nand_plat(pdev);
- staticstructs3c2410_platform_nand*to_nand_plat(structplatform_device*dev)
- {
- returndev->dev.platform_data;
- }
- s3c_nand_set_platdata(&mini2440_nand_info);
- /*NANDFlashonMINI2440board*/
- staticstructmtd_partitionmini2440_default_nand_part[]__initdata={
- [0]={
- .name="u-boot",
- .size=SZ_256K,
- .offset=0,
- },
- [1]={
- .name="u-boot-env",
- .size=S
Linux内核Nand驱动流程分 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)