driver core: clean up shutdown.c
[linux-2.6.git] / drivers / base / power / shutdown.c
1 /*
2  * shutdown.c - power management functions for the device tree.
3  *
4  * Copyright (c) 2002-3 Patrick Mochel
5  *               2002-3 Open Source Development Lab
6  *
7  * This file is released under the GPLv2
8  *
9  */
10
11 #include <linux/device.h>
12 #include <asm/semaphore.h>
13
14 #include "../base.h"
15
16 /**
17  * We handle system devices differently - we suspend and shut them
18  * down last and resume them first. That way, we don't do anything stupid like
19  * shutting down the interrupt controller before any devices..
20  *
21  * Note that there are not different stages for power management calls -
22  * they only get one called once when interrupts are disabled.
23  */
24
25
26 /**
27  * device_shutdown - call ->shutdown() on each device to shutdown.
28  */
29 void device_shutdown(void)
30 {
31         struct device * dev, *devn;
32
33         list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list,
34                                 kobj.entry) {
35                 if (dev->bus && dev->bus->shutdown) {
36                         dev_dbg(dev, "shutdown\n");
37                         dev->bus->shutdown(dev);
38                 } else if (dev->driver && dev->driver->shutdown) {
39                         dev_dbg(dev, "shutdown\n");
40                         dev->driver->shutdown(dev);
41                 }
42         }
43 }