summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-02-21 01:17:10 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2009-03-19 12:21:18 +0100
commit0b5a776c1e9cc6dec8d5fa6d2f97eb8f19d3d325 (patch)
tree55e998b87b5b4e1cc9b34ffffc02d7ea851239f6 /lib
parent36ae69a2dcb443bd3d55086f2f620e0057c9d6a6 (diff)
downloadbarebox-0b5a776c1e9cc6dec8d5fa6d2f97eb8f19d3d325.tar.gz
barebox-0b5a776c1e9cc6dec8d5fa6d2f97eb8f19d3d325.tar.xz
Shutdown U-Boot before starting an OS
Some devices, especially the ones doing DMA should be disabled before giving control to an OS. We take the simple approach here: Just shutdown the devices in the reverse order they were activated. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/driver.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/driver.c b/lib/driver.c
index 5aa643d03c..d722b09494 100644
--- a/lib/driver.c
+++ b/lib/driver.c
@@ -40,6 +40,8 @@ EXPORT_SYMBOL(device_list);
LIST_HEAD(driver_list);
EXPORT_SYMBOL(driver_list);
+static LIST_HEAD(active);
+
struct device_d *get_device_by_id(const char *id)
{
struct device_d *dev;
@@ -77,6 +79,8 @@ static int match(struct driver_d *drv, struct device_d *dev)
dev->driver = drv;
+ list_add(&dev->active, &active);
+
return 0;
}
@@ -326,6 +330,16 @@ const char *dev_id(const struct device_d *dev)
return buf;
}
+void devices_shutdown(void)
+{
+ struct device_d *dev;
+
+ list_for_each_entry(dev, &active, active) {
+ if (dev->driver->remove)
+ dev->driver->remove(dev);
+ }
+}
+
#ifdef CONFIG_CMD_DEVINFO
static int do_devinfo ( cmd_tbl_t *cmdtp, int argc, char *argv[])