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

    这一结构体

  • 相关阅读:
    SoapUI 使用笔记
    git 使用笔记(二)
    git 使用笔记(一)
    jquery 拓展
    hdu 1024 Max Sum Plus Plus (DP)
    hdu 2602 Bone Collector (01背包)
    hdu 1688 Sightseeing (最短路径)
    hdu 3191 How Many Paths Are There (次短路径数)
    hdu 2722 Here We Go(relians) Again (最短路径)
    hdu 1596 find the safest road (最短路径)
  • 原文地址:https://www.cnblogs.com/zongfanstudy/p/13753653.html
Copyright © 2011-2022 走看看