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,                
    }    

    这一结构体

  • 相关阅读:
    如何写UCHOME移动接口
    无限分类数据树形格式化
    linux下安装eclipse
    python编辑器对比和推荐
    黑马程序员面向对象07天6 (final)
    黑马程序员面向对象07天4 (super,this)
    黑马程序员面向对象07天8 (模版方法)
    黑马程序员面向对象07天7 (接口Interface)
    黑马程序员面向对象08天2 (多态)
    黑马程序员面向对象07天2 (抽象类测试)
  • 原文地址:https://www.cnblogs.com/zongfanstudy/p/13753653.html
Copyright © 2011-2022 走看看