shutdown.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. /**
  14. * We handle system devices differently - we suspend and shut them
  15. * down last and resume them first. That way, we don't do anything stupid like
  16. * shutting down the interrupt controller before any devices..
  17. *
  18. * Note that there are not different stages for power management calls -
  19. * they only get one called once when interrupts are disabled.
  20. */
  21. /**
  22. * device_shutdown - call ->shutdown() on each device to shutdown.
  23. */
  24. void device_shutdown(void)
  25. {
  26. struct device * dev, *devn;
  27. list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list,
  28. kobj.entry) {
  29. if (dev->bus && dev->bus->shutdown) {
  30. dev_dbg(dev, "shutdown\n");
  31. dev->bus->shutdown(dev);
  32. } else if (dev->driver && dev->driver->shutdown) {
  33. dev_dbg(dev, "shutdown\n");
  34. dev->driver->shutdown(dev);
  35. }
  36. }
  37. }