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

    这一结构体

  • 相关阅读:
    在React中使用Redux数据流
    开发中经常遇到的一些css样式问题
    记录一下CSS outline-width 属性
    使用git stash命令保存和恢复进度
    一分钟搭建好webpack通用坏境
    二维码生成(QRCode.js)
    IE6浏览器有哪些常见的bug,缺陷或者与标准不一致的地方,如何解决
    如何进行网站性能优化
    JavaScript深拷贝与浅拷贝的理解
    新问题: 两个样式对同一个元素操作,为什么最新的样式没有起作用?(已解决)
  • 原文地址:https://www.cnblogs.com/zongfanstudy/p/13753653.html
Copyright © 2011-2022 走看看