zoukankan      html  css  js  c++  java
  • SIMPLE_DEV_PM_OPS宏

    SYSTEM_SLEEP_PM_OPS和dev_pm_ops的定义:

    [cpp] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)   
    2.     .suspend = suspend_fn,   
    3.     .resume = resume_fn,   
    4.     .freeze = suspend_fn,   
    5.     .thaw = resume_fn,   
    6.     .poweroff = suspend_fn,   
    7.     .restore = resume_fn,  
    8.   
    9. struct dev_pm_ops {  
    10.     int (*prepare)(struct device *dev);  
    11.     void (*complete)(struct device *dev);  
    12.     int (*suspend)(struct device *dev);  
    13.     int (*resume)(struct device *dev);  
    14.     int (*freeze)(struct device *dev);  
    15.     int (*thaw)(struct device *dev);  
    16.     int (*poweroff)(struct device *dev);  
    17.     int (*restore)(struct device *dev);  
    18.     int (*suspend_noirq)(struct device *dev);  
    19.     int (*resume_noirq)(struct device *dev);  
    20.     int (*freeze_noirq)(struct device *dev);  
    21.     int (*thaw_noirq)(struct device *dev);  
    22.     int (*poweroff_noirq)(struct device *dev);  
    23.     int (*restore_noirq)(struct device *dev);  
    24.     int (*runtime_suspend)(struct device *dev);  
    25.     int (*runtime_resume)(struct device *dev);  
    26.     int (*runtime_idle)(struct device *dev);  
    27. };  
    struct platform_driver中的driver成员也有一个dev_pm_ops

    [cpp] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. struct platform_driver {  
    2.     int (*probe)(struct platform_device *);  
    3.     int (*remove)(struct platform_device *);  
    4.     void (*shutdown)(struct platform_device *);  
    5.     int (*suspend)(struct platform_device *, pm_message_t state);  
    6.     int (*resume)(struct platform_device *);  
    7.     struct device_driver driver;  
    8.     const struct platform_device_id *id_table;  
    9. };  
    10.   
    11. struct device_driver {  
    12.     const char      *name;  
    13.     struct bus_type     *bus;  
    14.   
    15.     struct module       *owner;  
    16.     const char      *mod_name;  /* used for built-in modules */  
    17.   
    18.     bool suppress_bind_attrs;   /* disables bind/unbind via sysfs */  
    19.   
    20.     const struct of_device_id   *of_match_table;  
    21.   
    22.     int (*probe) (struct device *dev);  
    23.     int (*remove) (struct device *dev);  
    24.     void (*shutdown) (struct device *dev);  
    25.     int (*suspend) (struct device *dev, pm_message_t state);  
    26.     int (*resume) (struct device *dev);  
    27.     const struct attribute_group **groups;  
    28.   
    29.     const struct dev_pm_ops *pm;  
    30.   
    31.     struct driver_private *p;  
    32. };  
    那么可以将宏SIMPLE_DEV_PM_OPS使用到struct platform_driver定义中,例如gpio-keys.c中:

    [cpp] view plain copy
     在CODE上查看代码片派生到我的代码片
    1. static SIMPLE_DEV_PM_OPS(gpio_keys_pm_ops, gpio_keys_suspend, gpio_keys_resume);  
    2.   
    3. static struct platform_driver gpio_keys_device_driver = {  
    4.     .probe      = gpio_keys_probe,  
    5.     .remove     = __devexit_p(gpio_keys_remove),  
    6.     .driver     = {  
    7.         .name   = "gpio-keys",  
    8.         .owner  = THIS_MODULE,  
    9.         .pm = &gpio_keys_pm_ops,  
    10.         .of_match_table = gpio_keys_of_match,  
    11.     }  
    12. };  
  • 相关阅读:
    线段树、最短路径、最小生成树、并查集、二分图匹配、最近公共祖先--C++模板
    数据结构中各种树
    你必须知道的基本位运算技巧(状压DP、搜索优化都会用到)
    memset为int型数组初始化问题
    Dev-C++添加代码格式化(format source code)工具Artistic Style
    让vs IIS Express支持本地静态Json文件
    什么是「供给侧改革」? 原标题:中央提的“供给侧改革”是啥意思?有谁能解说下吗?
    PowerDesigner用法和技巧
    php 调用 web Server(短信接口示例)
    sae相关配置
  • 原文地址:https://www.cnblogs.com/liang123/p/6325187.html
Copyright © 2011-2022 走看看