zoukankan      html  css  js  c++  java
  • device_init_wakeup()


    static inline int device_init_wakeup(struct device *dev, bool val)
    {
        device_set_wakeup_capable(dev, val);   //设置设备能不能被唤醒
        device_set_wakeup_enable(dev, val);     //设置设备使不使用唤醒;
        return 0;

    }

    // 设备模型中的 所有设备 都有两个标志来控制 唤醒事件(可使得设备或系统退出低功耗状态)。

    static inline void device_set_wakeup_capable(struct device *dev, bool capable)
    {
        dev->power.can_wakeup = capable;
    }


    static inline int device_set_wakeup_enable(struct device *dev, bool enable)
    {
        dev->power.should_wakeup = enable;
        return 0;
    }



    要认识device_init_wakeup(),首先需要知道两个概念:can_wakeup和should_wakeup。这两个家伙从哪里来的?看struct device结构体,里面有一个成员struct dev_pm_info power,来看一看struct dev_pm_info,来自include/linux/pm.h文件:

    1. 265 struct dev_pm_info {    
    2. 266     pm_message_t            power_state;    
    3. 267     unsigned                can_wakeup:1;    
    4. 268 #ifdef  CONFIG_PM    
    5. 269         unsigned                should_wakeup:1;    
    6. 270     pm_message_t            prev_state;    
    7. 271     void                    * saved_state;    
    8. 272     struct device           * pm_parent;    
    9. 273     struct list_head        entry;    
    10. 274 #endif    
    11. 275 };    


     

    这些都是电源管理部分的核心数据结构,显然,我们没有必要深入研究,只是需要知道,can_wakeup为1时 表明一个设备可以被唤醒,设备驱动为了支持Linux中的电源管理,有责任调用device_init_wakeup()来初始化can_wakeup。而should_wakeup则是在设备的 电源状态发生变化时 被device_may_wakeup()用来测试,测试它该不该变化

    因此,can_wakeup表明的是一种能力,should_wakeup表明的是有了这种能力以后去不去做某件事。













  • 相关阅读:
    第十一周作业
    第十周作业
    第九周编程
    第十二周作业
    第十一周作业
    第十周作业
    第八周作业
    第七周作业
    第五周作业
    2019春季学期第四周作业
  • 原文地址:https://www.cnblogs.com/liulaolaiu/p/11744575.html
Copyright © 2011-2022 走看看