power.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include <linux/pm_qos.h>
  2. #ifdef CONFIG_PM_RUNTIME
  3. extern void pm_runtime_init(struct device *dev);
  4. extern void pm_runtime_remove(struct device *dev);
  5. #else /* !CONFIG_PM_RUNTIME */
  6. static inline void pm_runtime_init(struct device *dev) {}
  7. static inline void pm_runtime_remove(struct device *dev) {}
  8. #endif /* !CONFIG_PM_RUNTIME */
  9. #ifdef CONFIG_PM_SLEEP
  10. /* kernel/power/main.c */
  11. extern int pm_async_enabled;
  12. /* drivers/base/power/main.c */
  13. extern struct list_head dpm_list; /* The active device list */
  14. static inline struct device *to_device(struct list_head *entry)
  15. {
  16. return container_of(entry, struct device, power.entry);
  17. }
  18. extern void device_pm_init(struct device *dev);
  19. extern void device_pm_add(struct device *);
  20. extern void device_pm_remove(struct device *);
  21. extern void device_pm_move_before(struct device *, struct device *);
  22. extern void device_pm_move_after(struct device *, struct device *);
  23. extern void device_pm_move_last(struct device *);
  24. #else /* !CONFIG_PM_SLEEP */
  25. static inline void device_pm_init(struct device *dev)
  26. {
  27. spin_lock_init(&dev->power.lock);
  28. dev->power.power_state = PMSG_INVALID;
  29. pm_runtime_init(dev);
  30. }
  31. static inline void device_pm_add(struct device *dev)
  32. {
  33. dev_pm_qos_constraints_init(dev);
  34. }
  35. static inline void device_pm_remove(struct device *dev)
  36. {
  37. dev_pm_qos_constraints_destroy(dev);
  38. pm_runtime_remove(dev);
  39. }
  40. static inline void device_pm_move_before(struct device *deva,
  41. struct device *devb) {}
  42. static inline void device_pm_move_after(struct device *deva,
  43. struct device *devb) {}
  44. static inline void device_pm_move_last(struct device *dev) {}
  45. #endif /* !CONFIG_PM_SLEEP */
  46. #ifdef CONFIG_PM
  47. /*
  48. * sysfs.c
  49. */
  50. extern int dpm_sysfs_add(struct device *dev);
  51. extern void dpm_sysfs_remove(struct device *dev);
  52. extern void rpm_sysfs_remove(struct device *dev);
  53. extern int wakeup_sysfs_add(struct device *dev);
  54. extern void wakeup_sysfs_remove(struct device *dev);
  55. extern int pm_qos_sysfs_add(struct device *dev);
  56. extern void pm_qos_sysfs_remove(struct device *dev);
  57. #else /* CONFIG_PM */
  58. static inline int dpm_sysfs_add(struct device *dev) { return 0; }
  59. static inline void dpm_sysfs_remove(struct device *dev) {}
  60. static inline void rpm_sysfs_remove(struct device *dev) {}
  61. static inline int wakeup_sysfs_add(struct device *dev) { return 0; }
  62. static inline void wakeup_sysfs_remove(struct device *dev) {}
  63. static inline int pm_qos_sysfs_add(struct device *dev) { return 0; }
  64. static inline void pm_qos_sysfs_remove(struct device *dev) {}
  65. #endif