[Linux]编写Linux驱动常见陷阱及解决办法
来源:互联网 发布:素材网站 知乎 编辑:程序博客网 时间:2024/06/05 20:53
问题1、驱动的init函数声明错误
出错:
[root@localhost]# insmod phyinfo.ko
insmod: error inserting 'phyinfo.ko': -159951552 Success
insmod: error inserting 'phyinfo.ko': -159951552 Success
原因:
驱动实现不对:
static void phyinfo_init(void)
{
......
......
}
module_init(phyinfo_init);
解决:
phyinfo_init函数必须有返回值!如可以实现定义如下:
static int phyinfo_init(void)
{
......
......
return 0;
}
问题2、linux/config.h头文件问题
出错:
/root/source/my-drivers/chartest/chartest.c:1:26: error: linux/config.h: No such file or directory
make[2]: *** [/root/source/my-drivers/chartest/chartest.o] Error 1
make[1]: *** [_module_/root/source/my-drivers/chartest] Error 2
make[1]: Leaving directory `/root/source/linux-2.6.30.5'
make: *** [modules] Error 2
make[2]: *** [/root/source/my-drivers/chartest/chartest.o] Error 1
make[1]: *** [_module_/root/source/my-drivers/chartest] Error 2
make[1]: Leaving directory `/root/source/linux-2.6.30.5'
make: *** [modules] Error 2
原因:
The file include/linux/config.h has been removed from 2.6.19 kernel.
解决:
1、把#include
#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H
#include
#endif
#define _LINUX_CONFIG_H
#include
#endif
2、直接删掉#include
3、touch一个空的linux/config.h
3、touch一个空的linux/config.h
- [Linux]编写Linux驱动常见陷阱及解决办法
- 编写Linux驱动常见错误
- 编写Linux驱动常见错误
- linux驱动编写过程中遇到的几个问题及解决办法
- linux按键驱动编写及测试程序
- Linux驱动程式编写
- 编写Linux设备驱动
- Linux驱动编写入门
- 如何编写linux驱动
- Linux按键驱动编写
- Linux编写驱动模块
- Linux驱动编写经验
- linux 简单驱动编写
- Linux网络编程中常见的陷阱
- SEP4020 Linux DMA驱动编写心得及使用流程
- linux socketcan驱动编写及使用(研华PCI-1680)
- linux最简单的驱动编写及测试流程
- arm+linux fl2440 ds18b20 温度传感器驱动编写及测试
- Oracle11g新特性之自动内存管理
- 原来是这种感觉
- [原创] WCF技术剖析之二十二: 深入剖析WCF底层异常处理框架实现原理[上篇]
- 自然框架的源代码下载(2009.10.28更新)
- 【自然框架】—— 全貌
- [Linux]编写Linux驱动常见陷阱及解决办法
- 广州技术沙龙第 3 期报名开始!
- IT餐馆—第二十回 银光
- 乾 乾为天 乾上乾下
- 微软帝国踏上Windows7征途(图)
- 精妙Sql语句
- 16个Javascript表单事件脚本(表单验证、选择)
- 搜狐继新闻门危机再陷版权官司缠身
- 移动的139说客说的是什么把戏?