Linux|驱动报错
试着移植linux-3.5下的mma7660.c到linux-4.4下,编译mma7660.c驱动时报错:
include/linux/bug.h:33:45: error: negative width in bit-field ''
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e);
}))
^
include/linux/kernel.h:831:3: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
BUILD_BUG_ON_ZERO((perms) & 2) +\
^
include/linux/sysfs.h:102:12: note: in expansion of macro 'VERIFY_OCTAL_PERMISSIONS'
.mode = VERIFY_OCTAL_PERMISSIONS(_mode) },\
^
include/linux/hwmon-sysfs.h:33:16: note: in expansion of macro '__ATTR'
{ .dev_attr = __ATTR(_name, _mode, _show, _store), \
^
include/linux/hwmon-sysfs.h:38:4: note: in expansion of macro 'SENSOR_ATTR'
= SENSOR_ATTR(_name, _mode, _show, _store, _index)
^
/work/driver/4412-dts/2th/mma7660.c:240:8: note: in expansion of macro 'SENSOR_DEVICE_ATTR'
static SENSOR_DEVICE_ATTR(registers, S_IRUGO | S_IWUGO,
^
/work/driver/4412-dts/2th/mma7660.c:49:16: warning: 'oper_mode' defined but not used [-Wunused-variable]
static intoper_mode;
^
scripts/Makefile.build:264: recipe for target '/work/driver/4412-dts/2th/mma7660.o' failed
make[2]: *** [/work/driver/4412-dts/2th/mma7660.o] Error 1
Makefile:1384: recipe for target '_module_/work/driver/4412-dts/2th' failed
make[1]: *** [_module_/work/driver/4412-dts/2th] Error 2
make[1]: Leaving directory '/work/linux-4.4'
Makefile:5: recipe for target 'all' failed
make: *** [all] Error 2
在谷歌上找到答案: 【Linux|驱动报错】
修改驱动中static SENSOR_DEVICE_ATTR(registers,S_IRUGO | S_IWUGO,mma7660_show_regs, mma7660_write_reg, 0);
把这个改为0660,over
然后出现警告:
WARNING: "input_register_polled_device" [/work/driver/4412-dts/2th/mma7660.ko] undefined!
WARNING: "input_allocate_polled_device" [/work/driver/4412-dts/2th/mma7660.ko] undefined!
WARNING: "input_free_polled_device" [/work/driver/4412-dts/2th/mma7660.ko] undefined!
WARNING: "input_unregister_polled_device" [/work/driver/4412-dts/2th/mma7660.ko] undefine
解决:
配置内核CONFIG_INPUT_POLLDEV,重新编译内核,over
推荐阅读
- Linux下面如何查看tomcat已经使用多少线程
- Beego打包部署到Linux
- 两感一练
- Linux|109 个实用 shell 脚本
- 接口|axios接口报错-参数类型错误解决
- linux定时任务contab
- 芯灵思SinlinxA33开发板Linux内核定时器编程
- day16-Linux|day16-Linux 软件管理
- 如何在阿里云linux上部署java项目
- Spring注解驱动第十讲--@Autowired使用