Rafael J. Wysocki | 1a9a915 | 2011-09-29 22:29:44 +0200 | [diff] [blame] | 1 | #include <linux/pm_qos.h> |
| 2 | |
Rafael J. Wysocki | e91c11b | 2012-08-06 01:44:28 +0200 | [diff] [blame^] | 3 | static inline void device_pm_init_common(struct device *dev) |
| 4 | { |
| 5 | spin_lock_init(&dev->power.lock); |
| 6 | dev->power.power_state = PMSG_INVALID; |
| 7 | } |
| 8 | |
Rafael J. Wysocki | 5e928f7 | 2009-08-18 23:38:32 +0200 | [diff] [blame] | 9 | #ifdef CONFIG_PM_RUNTIME |
| 10 | |
| 11 | extern void pm_runtime_init(struct device *dev); |
| 12 | extern void pm_runtime_remove(struct device *dev); |
| 13 | |
| 14 | #else /* !CONFIG_PM_RUNTIME */ |
| 15 | |
| 16 | static inline void pm_runtime_init(struct device *dev) {} |
| 17 | static inline void pm_runtime_remove(struct device *dev) {} |
| 18 | |
| 19 | #endif /* !CONFIG_PM_RUNTIME */ |
Alan Stern | 3b98aea | 2008-08-07 13:06:12 -0400 | [diff] [blame] | 20 | |
Rafael J. Wysocki | 296699d | 2007-07-29 23:27:18 +0200 | [diff] [blame] | 21 | #ifdef CONFIG_PM_SLEEP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Rafael J. Wysocki | 0e06b4a | 2010-01-23 22:25:15 +0100 | [diff] [blame] | 23 | /* kernel/power/main.c */ |
| 24 | extern int pm_async_enabled; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Rafael J. Wysocki | 0e06b4a | 2010-01-23 22:25:15 +0100 | [diff] [blame] | 26 | /* drivers/base/power/main.c */ |
Rafael J. Wysocki | 1eede07 | 2008-05-20 23:00:01 +0200 | [diff] [blame] | 27 | extern struct list_head dpm_list; /* The active device list */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Daniel Drake | dec13c1 | 2007-11-21 14:55:18 -0800 | [diff] [blame] | 29 | static inline struct device *to_device(struct list_head *entry) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
Alan Stern | cd59abf | 2007-09-21 15:36:56 -0400 | [diff] [blame] | 31 | return container_of(entry, struct device, power.entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Rafael J. Wysocki | e91c11b | 2012-08-06 01:44:28 +0200 | [diff] [blame^] | 34 | extern void device_pm_sleep_init(struct device *dev); |
Alan Stern | 3b98aea | 2008-08-07 13:06:12 -0400 | [diff] [blame] | 35 | extern void device_pm_add(struct device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | extern void device_pm_remove(struct device *); |
Cornelia Huck | ffa6a70 | 2009-03-04 12:44:00 +0100 | [diff] [blame] | 37 | extern void device_pm_move_before(struct device *, struct device *); |
| 38 | extern void device_pm_move_after(struct device *, struct device *); |
| 39 | extern void device_pm_move_last(struct device *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Rafael J. Wysocki | 5e928f7 | 2009-08-18 23:38:32 +0200 | [diff] [blame] | 41 | #else /* !CONFIG_PM_SLEEP */ |
| 42 | |
Rafael J. Wysocki | e91c11b | 2012-08-06 01:44:28 +0200 | [diff] [blame^] | 43 | static inline void device_pm_sleep_init(struct device *dev) {} |
Rafael J. Wysocki | 5e928f7 | 2009-08-18 23:38:32 +0200 | [diff] [blame] | 44 | |
Rafael J. Wysocki | 1a9a915 | 2011-09-29 22:29:44 +0200 | [diff] [blame] | 45 | static inline void device_pm_add(struct device *dev) |
| 46 | { |
| 47 | dev_pm_qos_constraints_init(dev); |
| 48 | } |
| 49 | |
Rafael J. Wysocki | 5e928f7 | 2009-08-18 23:38:32 +0200 | [diff] [blame] | 50 | static inline void device_pm_remove(struct device *dev) |
| 51 | { |
Rafael J. Wysocki | 1a9a915 | 2011-09-29 22:29:44 +0200 | [diff] [blame] | 52 | dev_pm_qos_constraints_destroy(dev); |
Rafael J. Wysocki | 5e928f7 | 2009-08-18 23:38:32 +0200 | [diff] [blame] | 53 | pm_runtime_remove(dev); |
| 54 | } |
Daniel Drake | dec13c1 | 2007-11-21 14:55:18 -0800 | [diff] [blame] | 55 | |
Cornelia Huck | ffa6a70 | 2009-03-04 12:44:00 +0100 | [diff] [blame] | 56 | static inline void device_pm_move_before(struct device *deva, |
| 57 | struct device *devb) {} |
| 58 | static inline void device_pm_move_after(struct device *deva, |
| 59 | struct device *devb) {} |
| 60 | static inline void device_pm_move_last(struct device *dev) {} |
Rafael J. Wysocki | 775b64d | 2008-01-12 20:40:46 +0100 | [diff] [blame] | 61 | |
Rafael J. Wysocki | 5e928f7 | 2009-08-18 23:38:32 +0200 | [diff] [blame] | 62 | #endif /* !CONFIG_PM_SLEEP */ |
Daniel Drake | dec13c1 | 2007-11-21 14:55:18 -0800 | [diff] [blame] | 63 | |
Rafael J. Wysocki | e91c11b | 2012-08-06 01:44:28 +0200 | [diff] [blame^] | 64 | static inline void device_pm_init(struct device *dev) |
| 65 | { |
| 66 | device_pm_init_common(dev); |
| 67 | device_pm_sleep_init(dev); |
| 68 | pm_runtime_init(dev); |
| 69 | } |
| 70 | |
Daniel Drake | dec13c1 | 2007-11-21 14:55:18 -0800 | [diff] [blame] | 71 | #ifdef CONFIG_PM |
| 72 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | /* |
| 74 | * sysfs.c |
| 75 | */ |
| 76 | |
Rafael J. Wysocki | cb8f51b | 2011-02-08 23:26:02 +0100 | [diff] [blame] | 77 | extern int dpm_sysfs_add(struct device *dev); |
| 78 | extern void dpm_sysfs_remove(struct device *dev); |
| 79 | extern void rpm_sysfs_remove(struct device *dev); |
| 80 | extern int wakeup_sysfs_add(struct device *dev); |
| 81 | extern void wakeup_sysfs_remove(struct device *dev); |
Rafael J. Wysocki | 85dc0b8 | 2012-03-13 01:01:39 +0100 | [diff] [blame] | 82 | extern int pm_qos_sysfs_add(struct device *dev); |
| 83 | extern void pm_qos_sysfs_remove(struct device *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Daniel Drake | dec13c1 | 2007-11-21 14:55:18 -0800 | [diff] [blame] | 85 | #else /* CONFIG_PM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
Rafael J. Wysocki | cb8f51b | 2011-02-08 23:26:02 +0100 | [diff] [blame] | 87 | static inline int dpm_sysfs_add(struct device *dev) { return 0; } |
| 88 | static inline void dpm_sysfs_remove(struct device *dev) {} |
| 89 | static inline void rpm_sysfs_remove(struct device *dev) {} |
| 90 | static inline int wakeup_sysfs_add(struct device *dev) { return 0; } |
| 91 | static inline void wakeup_sysfs_remove(struct device *dev) {} |
Rafael J. Wysocki | 85dc0b8 | 2012-03-13 01:01:39 +0100 | [diff] [blame] | 92 | static inline int pm_qos_sysfs_add(struct device *dev) { return 0; } |
| 93 | static inline void pm_qos_sysfs_remove(struct device *dev) {} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | #endif |