X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fbase%2Fpower%2Fshutdown.c;h=8826a5b6673eb9e4dfae4bb0d0b53126b77e4119;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=1164fcb7ad4f0a0189f1542bb0fac786fc65eefa;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c index 1164fcb7a..8826a5b66 100644 --- a/drivers/base/power/shutdown.c +++ b/drivers/base/power/shutdown.c @@ -1,9 +1,9 @@ /* * 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 * */ @@ -12,53 +12,41 @@ #include #include +#include "../base.h" #include "power.h" -#define to_dev(node) container_of(node,struct device,kobj.entry) +#define to_dev(node) container_of(node, struct device, kobj.entry) extern struct subsystem devices_subsys; -int device_detach_shutdown(struct device * dev) -{ - if (!dev->detach_state) - return 0; - - if (dev->detach_state == DEVICE_PM_OFF) { - if (dev->driver && dev->driver->shutdown) - dev->driver->shutdown(dev); - return 0; - } - return dpm_runtime_suspend(dev,dev->detach_state); -} - - /** - * We handle system devices differently - we suspend and shut them - * down first and resume them first. That way, we do anything stupid like + * 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. + * Note that there are not different stages for power management calls - + * they only get one called once when interrupts are disabled. */ -extern int sysdev_shutdown(void); /** - * device_shutdown - call ->remove() on each device to shutdown. + * device_shutdown - call ->shutdown() on each device to shutdown. */ void device_shutdown(void) { - struct device * dev; - + struct device * dev, *devn; + down_write(&devices_subsys.rwsem); - list_for_each_entry_reverse(dev,&devices_subsys.kset.list,kobj.entry) { - pr_debug("shutting down %s: ",dev->bus_id); - if (dev->driver && dev->driver->shutdown) { - pr_debug("Ok\n"); + list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list, + kobj.entry) { + if (dev->bus && dev->bus->shutdown) { + dev_dbg(dev, "shutdown\n"); + dev->bus->shutdown(dev); + } else if (dev->driver && dev->driver->shutdown) { + dev_dbg(dev, "shutdown\n"); dev->driver->shutdown(dev); - } else - pr_debug("Ignored.\n"); + } } up_write(&devices_subsys.rwsem);