shutdown.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * shutdown.c - power management functions for the device tree.
  3. *
  4. * Copyright (c) 2002-3 Patrick Mochel
  5. * 2002-3 Open Source Development Lab
  6. *
  7. * This file is released under the GPLv2
  8. *
  9. */
  10. #include <linux/device.h>
  11. #include <asm/semaphore.h>
  12. #include "../base.h"
  13. #include "power.h"
  14. #define to_dev(node) container_of(node, struct device, kobj.entry)
  15. /**
  16. * We handle system devices differently - we suspend and shut them
  17. * down last and resume them first. That way, we don't do anything stupid like
  18. * shutting down the interrupt controller before any devices..
  19. *
  20. * Note that there are not different stages for power management calls -
  21. * they only get one called once when interrupts are disabled.
  22. */
  23. /**
  24. * device_shutdown - call ->shutdown() on each device to shutdown.
  25. */
  26. void device_shutdown(void)
  27. {
  28. struct device * dev, *devn;
  29. list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.list,
  30. kobj.entry) {
  31. if (dev->bus && dev->bus->shutdown) {
  32. dev_dbg(dev, "shutdown\n");
  33. dev->bus->shutdown(dev);
  34. } else if (dev->driver && dev->driver->shutdown) {
  35. dev_dbg(dev, "shutdown\n");
  36. dev->driver->shutdown(dev);
  37. }
  38. }
  39. sysdev_shutdown();
  40. }