使用DEVICE

使用DEVICE,第1张

使用DEVICE 使用DEVICE_ATTR设置0666权限编译报错:

./include/linux/bug.h:37:45: error: negative width in bit-field ''
 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
                                             ^
./include/linux/kernel.h:857: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/device.h:578:45: note: in expansion of macro '__ATTR'
  struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
                                             ^
/home/ivan/ivan/Ecar507/longan/thirty/ltr_303/ltr_303als.c:355:8: note: in expansion of macro 'DEVICE_ATTR'
 static DEVICE_ATTR(ls_poll_delay, 0666,

------------------------------------------------------------解决方案-------------------------------------------------------

调用DEVICE_ATTR之前重新定义VERIFY_OCTAL_PERMISSIONS,至于原因,可以去跟踪DEVICE_ATTR这个宏的定义。

#undef VERIFY_OCTAL_PERMISSIONS
#define VERIFY_OCTAL_PERMISSIONS(parmx) (parmx)
static DEVICE_ATTR(lux, 0666,
                ltr303_als_lux_show,  NULL);
static DEVICE_ATTR(enable, 0666,
                NULL,  ltr303_enable_store);
static DEVICE_ATTR(ls_poll_delay, 0666,
                ltr303_delay_show,  ltr303_delay_store);
 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/3989398.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-10-21
下一篇 2022-10-21

发表评论

登录后才能评论

评论列表(0条)

保存