2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2006-01-19 16:30:17 +00:00
|
|
|
#include "../base.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "power.h"
|
|
|
|
|
|
|
|
#define to_dev(node) container_of(node, struct device, kobj.entry)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2006-01-09 09:04:51 +00:00
|
|
|
struct device * dev, *devn;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-04-13 20:15:19 +00:00
|
|
|
list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.list,
|
2005-05-09 15:07:00 +00:00
|
|
|
kobj.entry) {
|
2006-01-05 14:29:51 +00:00
|
|
|
if (dev->bus && dev->bus->shutdown) {
|
|
|
|
dev_dbg(dev, "shutdown\n");
|
|
|
|
dev->bus->shutdown(dev);
|
|
|
|
} else if (dev->driver && dev->driver->shutdown) {
|
2005-05-09 15:07:00 +00:00
|
|
|
dev_dbg(dev, "shutdown\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
dev->driver->shutdown(dev);
|
2005-05-09 15:07:00 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sysdev_shutdown();
|
|
|
|
}
|
|
|
|
|