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