• 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. };  
  • 相关阅读:
    爱奇艺RN低代码引擎:千变万化、快速搭建的万花筒
    前端性能优化实战 https://mp.weixin.qq.com/s/amaR6GJFqhW3B9TspBLWJA
    递归 回文链表
    字节跳动自研高性能微服务框架 Kitex 的演进之旅 https://mp.weixin.qq.com/s/DhraH24FuojgW26M8KdODQ
    Cigarette smokers problem
    万字长文 | 十个模型,总结产品经理沟通方法论 https://mp.weixin.qq.com/s/cfAVn1dIk8eg1ushxd0sA
    贪心 Partition Labels
    rune
    层层剖析一次 HTTP POST 请求事故
    runtime: shrink map as elements are deleted 缩容 垃圾回收 GC 内存
  • 原文地址:https://www.cnblogs.com/liang123/p/6325187.html
Copyright © 2020-2023  润新知