Commit 76d2b471 authored by Patrick Mochel's avatar Patrick Mochel

[driver model] Make sure we walk lists on shutdown in right order.

This takes advantage of the implicit list ordering of kobjects now present,
and uses list_for_each_entry() for simplicity.
parent c5c3f275
...@@ -49,19 +49,19 @@ extern int sysdev_restore(void); ...@@ -49,19 +49,19 @@ extern int sysdev_restore(void);
*/ */
int device_suspend(u32 state, u32 level) int device_suspend(u32 state, u32 level)
{ {
struct list_head * node; struct device * dev;
int error = 0; int error = 0;
printk(KERN_EMERG "Suspending devices\n"); printk(KERN_EMERG "Suspending devices\n");
down_write(&devices_subsys.rwsem); down_write(&devices_subsys.rwsem);
list_for_each(node,&devices_subsys.kset.list) { list_for_each_entry_reverse(dev,&devices_subsys.kset.list,kobj.entry) {
struct device * dev = to_dev(node);
if (dev->driver && dev->driver->suspend) { if (dev->driver && dev->driver->suspend) {
pr_debug("suspending device %s\n",dev->name); pr_debug("suspending device %s\n",dev->name);
error = dev->driver->suspend(dev,state,level); error = dev->driver->suspend(dev,state,level);
if (error) if (error)
printk(KERN_ERR "%s: suspend returned %d\n",dev->name,error); printk(KERN_ERR "%s: suspend returned %d\n",
dev->name,error);
} }
} }
up_write(&devices_subsys.rwsem); up_write(&devices_subsys.rwsem);
...@@ -93,7 +93,7 @@ int device_suspend(u32 state, u32 level) ...@@ -93,7 +93,7 @@ int device_suspend(u32 state, u32 level)
*/ */
void device_resume(u32 level) void device_resume(u32 level)
{ {
struct list_head * node; struct device * dev;
switch (level) { switch (level) {
case RESUME_POWER_ON: case RESUME_POWER_ON:
...@@ -107,8 +107,7 @@ void device_resume(u32 level) ...@@ -107,8 +107,7 @@ void device_resume(u32 level)
} }
down_write(&devices_subsys.rwsem); down_write(&devices_subsys.rwsem);
list_for_each_prev(node,&devices_subsys.kset.list) { list_for_each_entry(dev,&devices_subsys.kset.list,kobj.entry) {
struct device * dev = to_dev(node);
if (dev->driver && dev->driver->resume) { if (dev->driver && dev->driver->resume) {
pr_debug("resuming device %s\n",dev->name); pr_debug("resuming device %s\n",dev->name);
dev->driver->resume(dev,level); dev->driver->resume(dev,level);
...@@ -124,13 +123,12 @@ void device_resume(u32 level) ...@@ -124,13 +123,12 @@ void device_resume(u32 level)
*/ */
void device_shutdown(void) void device_shutdown(void)
{ {
struct list_head * entry; struct device * dev;
printk(KERN_EMERG "Shutting down devices\n"); printk(KERN_EMERG "Shutting down devices\n");
down_write(&devices_subsys.rwsem); down_write(&devices_subsys.rwsem);
list_for_each(entry,&devices_subsys.kset.list) { list_for_each_entry_reverse(dev,&devices_subsys.kset.list,kobj.entry) {
struct device * dev = to_dev(entry);
pr_debug("shutting down %s: ",dev->name); pr_debug("shutting down %s: ",dev->name);
if (dev->driver && dev->driver->shutdown) { if (dev->driver && dev->driver->shutdown) {
pr_debug("Ok\n"); pr_debug("Ok\n");
......
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