驱动报错

试着移植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 int     oper_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
在谷歌上找到答案:


修改驱动中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,Driver)