power.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #else /* CONFIG_PM */
  56. static inline int dpm_sysfs_add(struct device *dev) { return 0; }
  57. static inline void dpm_sysfs_remove(struct device *dev) {}
  58. static inline void rpm_sysfs_remove(struct device *dev) {}
  59. static inline int wakeup_sysfs_add(struct device *dev) { return 0; }
  60. static inline void wakeup_sysfs_remove(struct device *dev) {}
  61. #endif