zoukankan      html  css  js  c++  java
  • 通过SIMPLE_DEV_PM_OPS定义suspend和resume函数【转】

    本文转载自: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
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    java关键字synchronized
    JVM调优之jstack找出最耗cpu的线程并定位代码
    高性能Mysql
    awk使用入门
    JVM性能调优监控工具
    java垃圾回收算法
    JVM内存模型
    jvm之内存分配与回收策略
    leetcode 78. 子集(c++)
    leetcode 148. 排序链表(c++)
  • 原文地址:https://www.cnblogs.com/zzb-Dream-90Time/p/10211987.html
Copyright © 2011-2022 走看看