aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/shutdown.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/power/shutdown.c')
-rw-r--r--drivers/base/power/shutdown.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index f50a08be424b..c2475f3134ea 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -35,12 +35,15 @@ extern int sysdev_shutdown(void);
35 */ 35 */
36void device_shutdown(void) 36void device_shutdown(void)
37{ 37{
38 struct device * dev; 38 struct device * dev, *devn;
39 39
40 down_write(&devices_subsys.rwsem); 40 down_write(&devices_subsys.rwsem);
41 list_for_each_entry_reverse(dev, &devices_subsys.kset.list, 41 list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list,
42 kobj.entry) { 42 kobj.entry) {
43 if (dev->driver && dev->driver->shutdown) { 43 if (dev->bus && dev->bus->shutdown) {
44 dev_dbg(dev, "shutdown\n");
45 dev->bus->shutdown(dev);
46 } else if (dev->driver && dev->driver->shutdown) {
44 dev_dbg(dev, "shutdown\n"); 47 dev_dbg(dev, "shutdown\n");
45 dev->driver->shutdown(dev); 48 dev->driver->shutdown(dev);
46 } 49 }