通过SIMPLE_DEV_PM_OPS定义suspend和resume函数

通过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 = { \

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值