shutdown.c 1.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * shutdown.c - power management functions for the device tree.
 *
 * Copyright (c) 2002-3 Patrick Mochel
 *		 2002-3 Open Source Development Lab
 *
 * This file is released under the GPLv2
 *
 */

#include <linux/device.h>
#include <asm/semaphore.h>

14
#include "../base.h"
L
Linus Torvalds 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

/**
 * We handle system devices differently - we suspend and shut them
 * down last and resume them first. That way, we don't do anything stupid like
 * shutting down the interrupt controller before any devices..
 *
 * Note that there are not different stages for power management calls -
 * they only get one called once when interrupts are disabled.
 */


/**
 * device_shutdown - call ->shutdown() on each device to shutdown.
 */
void device_shutdown(void)
{
31
	struct device * dev, *devn;
L
Linus Torvalds 已提交
32

33
	list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list,
34
				kobj.entry) {
35 36 37 38
		if (dev->bus && dev->bus->shutdown) {
			dev_dbg(dev, "shutdown\n");
			dev->bus->shutdown(dev);
		} else if (dev->driver && dev->driver->shutdown) {
39
			dev_dbg(dev, "shutdown\n");
L
Linus Torvalds 已提交
40
			dev->driver->shutdown(dev);
41
		}
L
Linus Torvalds 已提交
42 43
	}
}