本文转载自:https://blog.csdn.net/tiantao2012/article/details/77851782

通过SIMPLE_DEV_PM_OPS 定义这个驱动的suspend和resume函数,如果没有定义CONFIG_PM_SLEEP的时候就将CONFIG_PM_SLEEP定义为空函数,这样可以避免build error
static SIMPLE_DEV_PM_OPS(asic3_led_pm_ops, asic3_led_suspend, asic3_led_resume);

static struct platform_driver asic3_led_driver = {
.probe = asic3_led_probe,
.remove = asic3_led_remove,
.driver = {
.name = "leds-asic3",
.pm = &asic3_led_pm_ops,
},
};
SIMPLE_DEV_PM_OPS 定义如下:
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
const struct dev_pm_ops name = { \
SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
}
如果定义CONFIG_PM_SLEEP的话,就给suspend和resume的函数指针赋值
#ifdef CONFIG_PM_SLEEP
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
.suspend = suspend_fn, \
.resume = resume_fn, \
.freeze = suspend_fn, \
.thaw = resume_fn, \
.poweroff = suspend_fn, \
.restore = resume_fn,
#else
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
#endif
可以看到如果没有定义CONFIG_PM_SLEEP的话,SIMPLE_DEV_PM_OPS 就相当于空函数
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
const struct dev_pm_ops name = { \
---------------------
作者:tiantao2012
来源:CSDN
原文:https://blog.csdn.net/tiantao2012/article/details/77851782
版权声明:本文为博主原创文章,转载请附上博文链接!

通过SIMPLE_DEV_PM_OPS定义suspend和resume函数【转】的更多相关文章

  1. Linux的系统suspend和resume

    参考: www.wowotech.net/linux_kenrel/suspend_and_resume.htmlwww.wowotech.net/linux_kenrel/pm_interface. ...

  2. (十二)Linux Kernel suspend and resume

    一.对于休眠(suspend)的简单介绍   在Linux中,休眠主要分三个主要的步骤:   1) 冻结用户态进程和内核态任务   2) 调用注册的设备的suspend的回调函数, 顺序是按照注册顺序 ...

  3. Java中的线程Thread方法之---suspend()和resume()

    前篇说到了Thread中的join方法,这一篇我们就来介绍一下suspend()和resume()方法,从字面意义上可以了解到这两个方法是一对的,suspend()方法就是将一个线程挂起(暂停),re ...

  4. 被废弃的 Thread.stop, Thread.suspend, Thread.resume 和Runtime.runFinalizersOnExit

    最近学习多线程的知识,看到API里说这些方法被废弃了,就查了一下原因 Thread.stop 这个方法会解除被加锁的对象的锁,因而可能造成这些对象处于不一致的状态,而且这个方法造成的ThreadDea ...

  5. Don’t use Suspend and Resume, but don’t poll either.

    http://www.paradicesoftware.com/blog/2014/02/dont-use-suspend-and-resume-but-dont-poll-either/ Don’t ...

  6. C语言利用va_list、va_start、va_end、va_arg宏定义可变参数的函数

    在定义可变参数的函数之前,先来理解一下函数参数的传递原理: 1.函数参数是以栈这种数据结构来存取的,在函数参数列表中,从右至左依次入栈. 2.参数的内存存放格式:参数的内存地址存放在内存的堆栈段中,在 ...

  7. c 可变参数 定义可变参数的函数

    定义可变参数的函数,需要在stdarg.h头文件中定义的va_list类型和va_start.va_arg.va_end三个宏. 定义可变参数函数 va_list ap;  //实际是定义一个指针va ...

  8. JAVA多线程suspend()、resume()和wait()、notify()的区别

    suspend() 和 resume() 方法:两个方法配套使用,suspend()使得线程进入阻塞状态,并且不会自动恢复,必须其对应的 resume() 被调用,才能使得线程重新进入可执行状态.典型 ...

  9. Why Are Thread.stop, Thread.suspend, Thread.resume and Runtime.runFinalizersOnExit Deprecated ?

    Thread.stop, Thread.suspend, Thread.resume被标记为废弃的方法.在查看JDK的文档时,提到了下面的参考文章,先是英文版,接着是中文翻译. Why is Thre ...

随机推荐

  1. report源码分析——report_handle和report_server和report_catcher

    report_handle主要实现对message的action,severity,file的设置,然后将message传递给server: 主要的function有两个:initial和proces ...

  2. html5-移动端布局模板

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  3. 电脑已连接wifi的密码查询

    有时候,想登陆自己家的无线网络(尤其朋友来家里突然要连接无线网络),脑子刹那间一片空白想不起来密码,怎么办呢? 其实,我们可以通过电脑来查看网络的密码,现在分享如何在笔记本电脑上查看连接过的无线网络密 ...

  4. Java WEB 笔记

    1. 部署并启动 tomcat 服务器 1). 解压 apache-tomcat-version 到一个非中文目录下 2). 配置一个环境变量,JAVA_HOME(指向 JDK 安装目录)或 JRE_ ...

  5. Struts2输入校验(XML方式)

    本章主要介绍struts2的XML配置方式输入校验.以下将结合一个实例程序进行说明. 代码结构: 关键代码: RegistAction.javapackage com.alfred.regist.ac ...

  6. Chrome插件消息传递实例

    首先吐槽"360极速浏览器应用开发平台"的开发文档,在消息传递(http://open.chrome.360.cn/extension_dev/messaging.html)一节中 ...

  7. Codeforces 237A - Free Cash

    题目链接:http://codeforces.com/problemset/problem/237/A Valera runs a 24/7 fast food cafe. He magically ...

  8. oracle 如何将一个字段内容拆分多行显示

    例子: select regexp_substr('1,2,3,4,5', '[^,]+', 1, level)from dualconnect by level <= regexp_count ...

  9. Python读写docx文件

    Python读写word文档有现成的库可以处理.我这里采用 python-docx.可以用pip install python-docx安装一下. 这里说一句,ppt和excel也有类似的库哦,而且是 ...

  10. 利用Oracle GoldenGate记录源系统所有表的操作

    通过goldengate,可以实现目标表和源表不同结构之间的实时复制,包括记录源系统所有表的变更操作,供ETL或其它审计系统使用. 记录信息包括表名.操作时间.操作SCN,事务标记,操作类型到一个流水 ...