- UID
- 1029342
- 性别
- 男
|
if (dev->bus) {
if(dev->bus->pm) {
pm_dev_dbg(dev, state, "");
error = pm_op(dev, dev->bus->pm,state);
} else if(dev->bus->suspend) {
pm_dev_dbg(dev, state, "legacy ");
error = dev->bus->suspend(dev,state);
suspend_report_result(dev->bus->suspend,error);
}
}
End:
up(&dev->sem);
return error;
}
4.2.2 进入阶段
回到suspend_devices_and_enter()再看suspend_enter(state)函数
static int suspend_enter(suspend_state_t state)
{
int error;
//调用体系结构相关的函数, 这是在系统初始化的时候注册的
if (suspend_ops->prepare) {
error= suspend_ops->prepare();
if (error)
return error;
}
error = device_power_down(PMSG_SUSPEND);
if (error) {
printk(KERN_ERR"PM: Some devices failed to power down\n");
goto Platfrom_finish;
}
if (suspend_ops->prepare_late){
error = suspend_ops->prepare_late();
if (error)
goto Power_up_devices;
}
if (suspend_test(TEST_PLATFORM))
goto Platform_wake;
error = disable_nonboot_cpus();
if (error ||suspend_test(TEST_CPUS))
gotoEnable_cpus;
arch_suspend_disable_irqs();
BUG_ON(!irqs_disabled());
error = sysdev_suspend(PMSG_SUSPEND);
if (!error) {
if (!suspend_test(TEST_CORE))
//调用体系结构相关的函数, 这是在系统初始化的时候注册的
error = suspend_ops->enter(state);
sysdev_resume();
}
arch_suspend_enable_irqs();
BUG_ON(irqs_disabled());
Enable_cpus:
enable_nonboot_cpus();
Platform_wake:
if (suspend_ops->wake)
suspend_ops->wake();
Power_up_devices:
device_power_up(PMSG_RESUME);
Platfrom_finish:
if (suspend_ops->finish)
//调用体系结构相关的函数, 这是在系统初始化的时候注册的
suspend_ops->finish();
return error;
}
这个suspend_ops就是在体系结构初始化的时候注册进来的,
接着看arch/arm/plat-s3c/pm.c
int __init s3c_pm_init(void)
{
printk("S3C Power Management,Copyright 2004 Simtec Electronics\n");
suspend_set_ops(&s3c_pm_ops);
return 0;
}
static struct platform_suspend_ops s3c_pm_ops = {
.enter = s3c_pm_enter,
.prepare = s3c_pm_prepare,
.finish = s3c_pm_finish,
.valid =suspend_valid_only_mem,
}; |
|