diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/base/power/shutdown.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/base/power/shutdown.c')
-rw-r--r-- | drivers/base/power/shutdown.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c new file mode 100644 index 000000000000..d1e023fbe169 --- /dev/null +++ b/drivers/base/power/shutdown.c | |||
@@ -0,0 +1,67 @@ | |||
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/config.h> | ||
12 | #include <linux/device.h> | ||
13 | #include <asm/semaphore.h> | ||
14 | |||
15 | #include "power.h" | ||
16 | |||
17 | #define to_dev(node) container_of(node, struct device, kobj.entry) | ||
18 | |||
19 | extern struct subsystem devices_subsys; | ||
20 | |||
21 | |||
22 | int device_detach_shutdown(struct device * dev) | ||
23 | { | ||
24 | if (!dev->detach_state) | ||
25 | return 0; | ||
26 | |||
27 | if (dev->detach_state == DEVICE_PM_OFF) { | ||
28 | if (dev->driver && dev->driver->shutdown) | ||
29 | dev->driver->shutdown(dev); | ||
30 | return 0; | ||
31 | } | ||
32 | return dpm_runtime_suspend(dev, dev->detach_state); | ||
33 | } | ||
34 | |||
35 | |||
36 | /** | ||
37 | * We handle system devices differently - we suspend and shut them | ||
38 | * down last and resume them first. That way, we don't do anything stupid like | ||
39 | * shutting down the interrupt controller before any devices.. | ||
40 | * | ||
41 | * Note that there are not different stages for power management calls - | ||
42 | * they only get one called once when interrupts are disabled. | ||
43 | */ | ||
44 | |||
45 | extern int sysdev_shutdown(void); | ||
46 | |||
47 | /** | ||
48 | * device_shutdown - call ->shutdown() on each device to shutdown. | ||
49 | */ | ||
50 | void device_shutdown(void) | ||
51 | { | ||
52 | struct device * dev; | ||
53 | |||
54 | down_write(&devices_subsys.rwsem); | ||
55 | list_for_each_entry_reverse(dev, &devices_subsys.kset.list, kobj.entry) { | ||
56 | pr_debug("shutting down %s: ", dev->bus_id); | ||
57 | if (dev->driver && dev->driver->shutdown) { | ||
58 | pr_debug("Ok\n"); | ||
59 | dev->driver->shutdown(dev); | ||
60 | } else | ||
61 | pr_debug("Ignored.\n"); | ||
62 | } | ||
63 | up_write(&devices_subsys.rwsem); | ||
64 | |||
65 | sysdev_shutdown(); | ||
66 | } | ||
67 | |||