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. };  
  • 相关阅读:
    今天写一篇随想,也当是回顾过去,展望未来吧。
    推荐 Word、EXCEL必备工具箱
    elasticsearch Routing 路由详解
    Python学习之字典
    ES 分片和副本数 调整及数据写入、重建索引调优
    fastJson JSON.parseObject()丢失字符串原本顺序
    Python 列表(详)
    pycharm常用快捷键
    Python学习笔记二(列表)
    python学习笔记二
  • 原文地址:https://www.cnblogs.com/liang123/p/6325187.html
Copyright © 2011-2022 走看看