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