zoukankan      html  css  js  c++  java
  • DEVICE_ATTR_RW 宏分析(转载)

    转自 https://blog.csdn.net/qq_35003588/article/details/102516512

    DEVICE_ATTR_RW 宏分析  举个例子 kernel/driver/rtc/rtc-sysfs.c   的宏分析 static DEVICE_ATTR_RW(wakealarm);

    static DEVICE_ATTR_RW(wakealarm);


    #define DEVICE_ATTR_RW(_name)
        struct device_attribute dev_attr_##_name = __ATTR_RW(_name)

        struct device_attribute dev_attr_(wakealarm) = __ATTR_RW(wakealarm);

        
    #define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO),    _name##_show, _name##_store)    
                 
    struct device_attribute dev_attr_(wakealarm) =  __ATTR(wakealarm, (S_IWUSR | S_IRUGO),wakealarm_show, wakealarm_store)         


    #define __ATTR(_name, _mode, _show, _store) {                
        .attr = {.name = __stringify(_name),                
             .mode = VERIFY_OCTAL_PERMISSIONS(_mode) },        
        .show    = _show,                        
        .store    = _store,                        
    }

    struct device_attribute dev_attr_(wakealarm) = {                
        .attr = {.name = __stringify(wakealarm),                
             .mode = VERIFY_OCTAL_PERMISSIONS((S_IWUSR | S_IRUGO)) },        
        .show    = wakealarm_show,                        
        .store    = wakealarm_store,                
    }    

    最终这个宏 static DEVICE_ATTR_RW(wakealarm);  生成了

    struct device_attribute dev_attr_(wakealarm) = {                
        .attr = {.name = __stringify(wakealarm),                
             .mode = VERIFY_OCTAL_PERMISSIONS((S_IWUSR | S_IRUGO)) },        
        .show    = wakealarm_show,                        
        .store    = wakealarm_store,                
    }    

    这一结构体

  • 相关阅读:
    事件DOMContentLoaded与load的区别
    JavaScript的执行环境
    JS中函数运行的执行次序
    正则表达式30分钟入门教程
    mysql数据库备份
    杂篇
    memcached
    mysql问题解决
    php学习
    apache 安装
  • 原文地址:https://www.cnblogs.com/zongfanstudy/p/13753653.html
Copyright © 2011-2022 走看看