ramoops具体失败原因来解释驱动寄存器
正在使用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具体失败原因来解释驱动寄存器的更多相关文章
- tomcat下服务启动失败原因
Tomcat启动成功,输入网址后可以显示小黄猫界面,但是在Tomcat下的服务却启动不成功,显示404(以Jenkins为例,运用多种方式查看原因) 注:1.单启动Tomcat服务是可以启动成功的. ...
- Tomcat启动失败原因
Tomcat启动失败原因 一.Tomcat启动时,要求被加载的项目必须拥有独立路径名称 发布的两个工程具有相同路径名称,这是不允许. 二.8080端口号已经被占用了 启动失败原因,就是8085端口上, ...
- 玩转Windows服务系列——无COM接口Windows服务启动失败原因及解决方案
将VS创建的Windows服务项目编译生成的程序,通过命令行 “服务.exe -Service”注册为Windows服务后,就可以通过服务管理器进行管理了. 问题 通过服务管理器进行启动的时候,发现服 ...
- pip install 提示代理连接失败原因及解决办法
# pip install 提示代理连接失败原因及解决办法 1. 错误提示 在公司电脑上安装Python的虚拟环境时输入命令: pip install virtualenv 系统提示以下异常信息: R ...
- 单点登录跳转失败(原因是 主票据申请子票据失败) asp.net 同站点下不同应用间不同版本Framework问题
单点登录跳转失败(原因是 主票据申请子票据失败) asp.net 同站点下不同应用间不同版本Framework问题 今天遇到一个问题,在主站点现在配置的应用和主站点登录会话状态不能共享,进入子站点应用 ...
- 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 ...
- 【HANA系列】SAP ECLIPSE中创建ABAP项目失败原因解析
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP ECLIPSE中创建AB ...
- Linux嵌入式学习-mount命令+nfs挂载失败原因【转】
NFS 挂载失败原因[待搜集] 1.挂载时若出现mount.nfs: Input/output error 解决:在客户端也需启动portmap服务 service portmap status[查看 ...
- dpdk组态 千兆网卡 驱动 失败 原因分析及 解决方案
dpdk版本号是1.7.1稳定版,server它是ubuntu12.04LTS x86 64bit 绑定默认驱动程序千兆网卡ixgbe失败 # ./dpdk_nic_bind.py -b ixgbe ...
随机推荐
- Android判断应用程序从后台回到前台
MainActivity如下: package cc.testbackgroundtofront; import java.util.List; import android.app.Activity ...
- 从零開始学android<SeekBar滑动组件.二十二.>
拖动条能够由用户自己进行手工的调节,比如:当用户须要调整播放器音量或者是电影的播放进度时都会使用到拖动条,SeekBar类的定义结构例如以下所看到的: java.lang.Object ↳ an ...
- 【Unity Shaders】使用CgInclude让你的Shader模块化——Unity内置的CgInclude文件
本系列主要參考<Unity Shaders and Effects Cookbook>一书(感谢原书作者),同一时候会加上一点个人理解或拓展. 这里是本书全部的插图. 这里是本书所需的代码 ...
- java中的特殊字符集合
JAVA中转义字符: 1.八进制转义序列:\ + 1到3位5数字:范围'\000'~'\377' \0:空字符 2.Unicode转义字符:\u + 四个 十六进制数字:0~65535 ...
- WPF界面设计技巧(9)—使用UI自动化布局
原文:WPF界面设计技巧(9)-使用UI自动化布局 最近一直没时间更新这系列文章,因为我一直在埋头编写我的第一个WPF应用程序:MailMail 今天开始编写附属的加密/解密工具,对UI自动化布局有些 ...
- A Game of Thrones(3) - Daenerys
Her brother held the gown up for her inspection. “This is beauty. Touch it. Go on. Caress(爱抚,抚抱) the ...
- poj3176--Cow Bowling(dp:数塔问题)
Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14028 Accepted: 9302 Desc ...
- 小试Office OneNote 2010的图片文字识别功能(OCR)
原文:小试Office OneNote 2010的图片文字识别功能(OCR) 自Office 2003以来,OneNote就成为了我电脑中必不可少的软件,它集各种创新功能于一身,可方便的记录下各种类型 ...
- oracle转Mysql中,varchar2(10)和number应该转换为什么类型? (转)
一. varchar2(10)和number应该转换为什么类型? oracle转成mysql时:varchar2(10)可以转成varchar(10)number则要看oracle中存储的具体是什么类 ...
- [TroubleShooting]'trn\bak' is incorrectly formed. SQL Server cannot process this media family.
SQL Server online consultants came across an interesting scenario where one of our client was una ...