pm_wakeup.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * pm_wakeup.h - Power management wakeup interface
  3. *
  4. * Copyright (C) 2008 Alan Stern
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef _LINUX_PM_WAKEUP_H
  21. #define _LINUX_PM_WAKEUP_H
  22. #ifndef _DEVICE_H_
  23. # error "please don't include this file directly"
  24. #endif
  25. #include <linux/types.h>
  26. #ifdef CONFIG_PM
  27. /* changes to device_may_wakeup take effect on the next pm state change.
  28. * by default, devices should wakeup if they can.
  29. */
  30. static inline void device_init_wakeup(struct device *dev, bool val)
  31. {
  32. dev->power.can_wakeup = dev->power.should_wakeup = val;
  33. }
  34. static inline void device_set_wakeup_capable(struct device *dev, bool capable)
  35. {
  36. dev->power.can_wakeup = capable;
  37. }
  38. static inline bool device_can_wakeup(struct device *dev)
  39. {
  40. return dev->power.can_wakeup;
  41. }
  42. static inline void device_set_wakeup_enable(struct device *dev, bool enable)
  43. {
  44. dev->power.should_wakeup = enable;
  45. }
  46. static inline bool device_may_wakeup(struct device *dev)
  47. {
  48. return dev->power.can_wakeup && dev->power.should_wakeup;
  49. }
  50. #else /* !CONFIG_PM */
  51. /* For some reason the next two routines work even without CONFIG_PM */
  52. static inline void device_init_wakeup(struct device *dev, bool val)
  53. {
  54. dev->power.can_wakeup = val;
  55. }
  56. static inline void device_set_wakeup_capable(struct device *dev, bool capable)
  57. {
  58. }
  59. static inline bool device_can_wakeup(struct device *dev)
  60. {
  61. return dev->power.can_wakeup;
  62. }
  63. static inline void device_set_wakeup_enable(struct device *dev, bool enable)
  64. {
  65. }
  66. static inline bool device_may_wakeup(struct device *dev)
  67. {
  68. return false;
  69. }
  70. #endif /* !CONFIG_PM */
  71. #endif /* _LINUX_PM_WAKEUP_H */