正在使用linux的ramoops驱动器模块,当编译完成加载。查找驱动程序加载失败。显然,直接用内核代码,为什么会出现这种情况?

第一眼ramoops初始化代码:

180 static int __init ramoops_init(void)
181 {
182 return platform_driver_probe(&ramoops_driver, ramoops_probe);
183 }
184
185 static void __exit ramoops_exit(void)
186 {
187 platform_driver_unregister(&ramoops_driver);
188 }
189
190 module_init(ramoops_init);

180行開始的ramoops_init函数是不是有点奇怪?直接就调用了probe函数。标准的platform驱动程序的流程是这种:

怎么看起来好像缺少platform_device的定义和注冊。究竟是不是由于这个呢?我们来看一下Document/ramoops.txt的相关说明:

 38 2. Setting the parameters
39
40 Setting the ramoops parameters can be done in 2 different manners:
41 1. Use the module parameters (which have the names of the variables described
42 as before).
43 For quick debugging, you can also reserve parts of memory during boot
44 and then use the reserved memory for ramoops. For example, assuming a machine
45 with > 128 MB of memory, the following kernel command line will tell the
46 kernel to use only the first 128 MB of memory, and place ECC-protected ramoops
47 region at 128 MB boundary:
48 "mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1"
49 2. Use a platform device and set the platform data. The parameters can then
50 be set through that platform data. An example of doing that is:
51
52 #include <linux/pstore_ram.h>
53 [...]
54
55 static struct ramoops_platform_data ramoops_data = {
56 .mem_size = <...>,
57 .mem_address = <...>,
58 .record_size = <...>,
59 .dump_oops = <...>,
60 .ecc = <...>,
61 };
62
63 static struct platform_device ramoops_dev = {
64 .name = "ramoops",
65 .dev = {
66 .platform_data = &ramoops_data,
67 },
68 };
69
70 [... inside a function ...]
71 int ret;
72
73 ret = platform_device_register(&ramoops_dev);
74 if (ret) {
75 printk(KERN_ERR "unable to register platform device\n");
76 return ret;
77 }

原来真的是由于少了platform_device的缘故,赶紧加上。

追加platform_device的操作比較简单,依照Document上的来就能够了。

有一点须要主要。就是ramoops_dev的name这个成员。这个成员的值必须是"ramoops"。为什么呢?这是由于platform总线在调用自身的match函数,将driver与device进行匹配时,就是推断两个结构体中的name成员是否相等。

而platform_driver结构体中的name成员的值,从以下的代码中能够看出,已经写定为"ramoops"。假设platform_device中的值不同,则驱动相同无法载入。

172 static struct platform_driver ramoops_driver = {
173 .remove = __exit_p(ramoops_remove),
174 .driver = {
175 .name = "ramoops",
176 .owner = THIS_MODULE,
177 },
178 };

有没有想过,为什么没注冊platform_device,ramoops的驱动代码就不能载入呢?再回过头来看一下ramoops的初始化代码:

180 static int __init ramoops_init(void)
181 {
182 return platform_driver_probe(&ramoops_driver, ramoops_probe);
183 }

之前说过,一般init函数中会调用register函数,还说这是标准流程了呢。看一下platform_driver_probe函数的定义:

 477 int __init_or_module platform_driver_probe(struct platform_driver *drv,
478 int (*probe)(struct platform_device *))
479 {
480 int retval, code;
481
482 /* make sure driver won't have bind/unbind attributes */
483 drv->driver.suppress_bind_attrs = true;
484
485 /* temporary section violation during probe() */
486 drv->probe = probe;
487 retval = code = platform_driver_register(drv);
488
。 。 。 }

看到platform_driver_register函数没?原来是将register函数封装了一层。

看到这里应该明确了,为什么没有注冊platform_device。驱动会载入失败了吧。

什么,还是不知道?那你一定没看我之前写的关于linux设备驱动程序的注冊流程。假设看完了还没明确,那就是我的问题。链接在此:http://blog.csdn.net/tuzhutuzhu/article/details/34847619

版权声明:本文博主原创文章,博客,未经同意不得转载。

ramoops具体失败原因来解释驱动寄存器的更多相关文章

  1. tomcat下服务启动失败原因

    Tomcat启动成功,输入网址后可以显示小黄猫界面,但是在Tomcat下的服务却启动不成功,显示404(以Jenkins为例,运用多种方式查看原因) 注:1.单启动Tomcat服务是可以启动成功的. ...

  2. Tomcat启动失败原因

    Tomcat启动失败原因 一.Tomcat启动时,要求被加载的项目必须拥有独立路径名称 发布的两个工程具有相同路径名称,这是不允许. 二.8080端口号已经被占用了 启动失败原因,就是8085端口上, ...

  3. 玩转Windows服务系列——无COM接口Windows服务启动失败原因及解决方案

    将VS创建的Windows服务项目编译生成的程序,通过命令行 “服务.exe -Service”注册为Windows服务后,就可以通过服务管理器进行管理了. 问题 通过服务管理器进行启动的时候,发现服 ...

  4. pip install 提示代理连接失败原因及解决办法

    # pip install 提示代理连接失败原因及解决办法 1. 错误提示 在公司电脑上安装Python的虚拟环境时输入命令: pip install virtualenv 系统提示以下异常信息: R ...

  5. 单点登录跳转失败(原因是 主票据申请子票据失败) asp.net 同站点下不同应用间不同版本Framework问题

    单点登录跳转失败(原因是 主票据申请子票据失败) asp.net 同站点下不同应用间不同版本Framework问题 今天遇到一个问题,在主站点现在配置的应用和主站点登录会话状态不能共享,进入子站点应用 ...

  6. mysql创建唯一索引UNIQUE INDEX,以及报错“#失败原因: [Execute: Duplicate entry '733186700' for key 'uniq_video_id_index']”

    要给t_video_prods表的video_id字段创建唯一所以,可以使用下面这条语句: alter table t_video_prods add UNIQUE INDEX `uniq_video ...

  7. 【HANA系列】SAP ECLIPSE中创建ABAP项目失败原因解析

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP ECLIPSE中创建AB ...

  8. Linux嵌入式学习-mount命令+nfs挂载失败原因【转】

    NFS 挂载失败原因[待搜集] 1.挂载时若出现mount.nfs: Input/output error 解决:在客户端也需启动portmap服务 service portmap status[查看 ...

  9. dpdk组态 千兆网卡 驱动 失败 原因分析及 解决方案

    dpdk版本号是1.7.1稳定版,server它是ubuntu12.04LTS x86 64bit 绑定默认驱动程序千兆网卡ixgbe失败 # ./dpdk_nic_bind.py -b ixgbe ...

随机推荐

  1. VS上的WebService入门贴

    由于项目需要,最近要熟悉一下通过IIS发布WebService.首先熟悉一下使用VS来创建webservice并且调用它. //------------------------------------ ...

  2. hdu 4961 Boring Sum(数学题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4961 Problem Description Number theory is interesting ...

  3. Android_模拟时钟内时针、分针触摸转动

    最近实现了android里的一个机能,在activity里面画了一个模拟的时针,然后触摸上面的时针跟分针可以实现调时间的功能. 其实,说起原来来还是挺简单的,但是我花了将近一周的时间才全部实现,有点惭 ...

  4. ajax相关体会

    参考原文: 例子:http://blog.csdn.net/beijiguangyong/article/details/7725596 原理讲解:http://www.cnblogs.com/min ...

  5. jquery 弹出登陆框,简单易懂!修改密码效果代码

    在网上找了一大堆,看的眼花瞭乱,还是研究原码,自已搞出来了! ui原地址:http://jqueryui.com/dialog/#modal-form 可以把js,css下载到本地,要不然不联网的话, ...

  6. wordpress博客近期变慢之解决(fonts.google.com)

    近期发现站点訪问速度变慢.博客文章打开速度特慢,也没改动过东西. 并且近期发现google的服务非常多訪问都打不开或是变慢. 于是知道可能是那"伟大东西"在作坏事了. 症状: 网页 ...

  7. 日历的问题C语言,C++(boost),python,Javascript,Java和Matlab实现

    今天看到一个很有意思的话题,例的标题叙述性描述,下面: 根据以下信息来计算1901年1月1至2000年12月31适逢星期日每个月的第一天的合伙人数量? a)  1900.1.1星期一 b)  1月,3 ...

  8. 做web项目时对代码修改后浏览器端不生效的应对方法(持续更新)

    做web项目时,经常会遇到修改了代码,但浏览器端没有生效,原因是多种多样的,我会根据我遇到的情况逐步更新解决办法 1.运行的时候采用debug模式,一般情况下使用项目部署按钮右边那个按钮下的tomca ...

  9. web:转盘抽奖

    移动web:转盘抽奖(幸运大转盘)   为了获取客户.回馈客户,平台一般会推出抽奖活动类的营销页.因此web页面中,有各式各样的抽奖效果. 格子式(九宫格),背景滚动式(数字/文字/图案),旋转式(转 ...

  10. ubuntu下安装wine

    直接在终端里面输入“sudo apt-get install wine”不要引号,即可安装wine.至于使用它,终端命令就是“wine ....”举个例子,你现在要运行魔兽, 然后你的魔兽的文件夹的位 ...