Driver core: remove use of rwsem
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / base / power / shutdown.c
blob58b6f77a1b340f3bfc70527758c501be18ed6f52
1 /*
2 * shutdown.c - power management functions for the device tree.
4 * Copyright (c) 2002-3 Patrick Mochel
5 * 2002-3 Open Source Development Lab
7 * This file is released under the GPLv2
9 */
11 #include <linux/device.h>
12 #include <asm/semaphore.h>
14 #include "../base.h"
15 #include "power.h"
17 #define to_dev(node) container_of(node, struct device, kobj.entry)
19 extern struct subsystem devices_subsys;
22 /**
23 * We handle system devices differently - we suspend and shut them
24 * down last and resume them first. That way, we don't do anything stupid like
25 * shutting down the interrupt controller before any devices..
27 * Note that there are not different stages for power management calls -
28 * they only get one called once when interrupts are disabled.
32 /**
33 * device_shutdown - call ->shutdown() on each device to shutdown.
35 void device_shutdown(void)
37 struct device * dev, *devn;
39 list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list,
40 kobj.entry) {
41 if (dev->bus && dev->bus->shutdown) {
42 dev_dbg(dev, "shutdown\n");
43 dev->bus->shutdown(dev);
44 } else if (dev->driver && dev->driver->shutdown) {
45 dev_dbg(dev, "shutdown\n");
46 dev->driver->shutdown(dev);
50 sysdev_shutdown();