Commit 9777b1de authored by Patrick Mochel's avatar Patrick Mochel

[driver model] Make sure that system devices are handled specially power-wise

- Suspend system devices last, after interrupts have been enabled. 
- Resume them first, before interrupts are enabled. 
- Shut them down last, after everything else.
parent 651d7ed2
......@@ -21,6 +21,19 @@
extern struct subsystem devices_subsys;
/**
* We handle system devices differently - we suspend and shut them
* down first and resume them first. That way, we do anything stupid like
* shutting down the interrupt controller before any devices..
*
* Note that there are not different stages for power management calls -
* they only get one called once when interrupts are disabled.
*/
extern int sys_device_shutdown(void);
extern int sys_device_suspend(u32 state);
extern int sys_device_resume(void);
/**
* device_suspend - suspend/remove all devices on the device ree
* @state: state we're entering
......@@ -50,6 +63,10 @@ int device_suspend(u32 state, u32 level)
}
}
up_write(&devices_subsys.rwsem);
if (level == SUSPEND_POWER_DOWN)
sys_device_suspend(state);
return error;
}
......@@ -65,6 +82,9 @@ void device_resume(u32 level)
{
struct list_head * node;
if (level == RESUME_POWER_ON)
sys_device_resume();
down_write(&devices_subsys.rwsem);
list_for_each_prev(node,&devices_subsys.kset.list) {
struct device * dev = to_dev(node);
......@@ -98,6 +118,8 @@ void device_shutdown(void)
pr_debug("Ignored.\n");
}
up_write(&devices_subsys.rwsem);
sys_device_shutdown();
}
EXPORT_SYMBOL(device_suspend);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment