diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2008-10-06 16:46:05 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 13:44:29 -0500 |
commit | adf094931ffb25ef4b381559918f1a34181a5273 (patch) | |
tree | bd343d4c15b21dff6a73359fd2d82ff77e30e0d4 /include/linux/pm.h | |
parent | 238c6d54830c624f34ac9cf123ac04aebfca5013 (diff) |
PM: Simplify the new suspend/hibernation framework for devices
PM: Simplify the new suspend/hibernation framework for devices
Following the discussion at the Kernel Summit, simplify the new
device PM framework by merging 'struct pm_ops' and
'struct pm_ext_ops' and removing pointers to 'struct pm_ext_ops'
from 'struct platform_driver' and 'struct pci_driver'.
After this change, the suspend/hibernation callbacks will only
reside in 'struct device_driver' as well as at the bus type/
device class/device type level. Accordingly, PCI and platform
device drivers are now expected to put their suspend/hibernation
callbacks into the 'struct device_driver' embedded in
'struct pci_driver' or 'struct platform_driver', respectively.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@suse.cz>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/pm.h')
-rw-r--r-- | include/linux/pm.h | 76 |
1 files changed, 25 insertions, 51 deletions
diff --git a/include/linux/pm.h b/include/linux/pm.h index 42de4003c4ee..5785666d0cc4 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h | |||
@@ -41,7 +41,7 @@ typedef struct pm_message { | |||
41 | } pm_message_t; | 41 | } pm_message_t; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * struct pm_ops - device PM callbacks | 44 | * struct dev_pm_ops - device PM callbacks |
45 | * | 45 | * |
46 | * Several driver power state transitions are externally visible, affecting | 46 | * Several driver power state transitions are externally visible, affecting |
47 | * the state of pending I/O queues and (for drivers that touch hardware) | 47 | * the state of pending I/O queues and (for drivers that touch hardware) |
@@ -126,46 +126,6 @@ typedef struct pm_message { | |||
126 | * On most platforms, there are no restrictions on availability of | 126 | * On most platforms, there are no restrictions on availability of |
127 | * resources like clocks during @restore(). | 127 | * resources like clocks during @restore(). |
128 | * | 128 | * |
129 | * All of the above callbacks, except for @complete(), return error codes. | ||
130 | * However, the error codes returned by the resume operations, @resume(), | ||
131 | * @thaw(), and @restore(), do not cause the PM core to abort the resume | ||
132 | * transition during which they are returned. The error codes returned in | ||
133 | * that cases are only printed by the PM core to the system logs for debugging | ||
134 | * purposes. Still, it is recommended that drivers only return error codes | ||
135 | * from their resume methods in case of an unrecoverable failure (i.e. when the | ||
136 | * device being handled refuses to resume and becomes unusable) to allow us to | ||
137 | * modify the PM core in the future, so that it can avoid attempting to handle | ||
138 | * devices that failed to resume and their children. | ||
139 | * | ||
140 | * It is allowed to unregister devices while the above callbacks are being | ||
141 | * executed. However, it is not allowed to unregister a device from within any | ||
142 | * of its own callbacks. | ||
143 | */ | ||
144 | |||
145 | struct pm_ops { | ||
146 | int (*prepare)(struct device *dev); | ||
147 | void (*complete)(struct device *dev); | ||
148 | int (*suspend)(struct device *dev); | ||
149 | int (*resume)(struct device *dev); | ||
150 | int (*freeze)(struct device *dev); | ||
151 | int (*thaw)(struct device *dev); | ||
152 | int (*poweroff)(struct device *dev); | ||
153 | int (*restore)(struct device *dev); | ||
154 | }; | ||
155 | |||
156 | /** | ||
157 | * struct pm_ext_ops - extended device PM callbacks | ||
158 | * | ||
159 | * Some devices require certain operations related to suspend and hibernation | ||
160 | * to be carried out with interrupts disabled. Thus, 'struct pm_ext_ops' below | ||
161 | * is defined, adding callbacks to be executed with interrupts disabled to | ||
162 | * 'struct pm_ops'. | ||
163 | * | ||
164 | * The following callbacks included in 'struct pm_ext_ops' are executed with | ||
165 | * the nonboot CPUs switched off and with interrupts disabled on the only | ||
166 | * functional CPU. They also are executed with the PM core list of devices | ||
167 | * locked, so they must NOT unregister any devices. | ||
168 | * | ||
169 | * @suspend_noirq: Complete the operations of ->suspend() by carrying out any | 129 | * @suspend_noirq: Complete the operations of ->suspend() by carrying out any |
170 | * actions required for suspending the device that need interrupts to be | 130 | * actions required for suspending the device that need interrupts to be |
171 | * disabled | 131 | * disabled |
@@ -190,18 +150,32 @@ struct pm_ops { | |||
190 | * actions required for restoring the operations of the device that need | 150 | * actions required for restoring the operations of the device that need |
191 | * interrupts to be disabled | 151 | * interrupts to be disabled |
192 | * | 152 | * |
193 | * All of the above callbacks return error codes, but the error codes returned | 153 | * All of the above callbacks, except for @complete(), return error codes. |
194 | * by the resume operations, @resume_noirq(), @thaw_noirq(), and | 154 | * However, the error codes returned by the resume operations, @resume(), |
195 | * @restore_noirq(), do not cause the PM core to abort the resume transition | 155 | * @thaw(), @restore(), @resume_noirq(), @thaw_noirq(), and @restore_noirq() do |
196 | * during which they are returned. The error codes returned in that cases are | 156 | * not cause the PM core to abort the resume transition during which they are |
197 | * only printed by the PM core to the system logs for debugging purposes. | 157 | * returned. The error codes returned in that cases are only printed by the PM |
198 | * Still, as stated above, it is recommended that drivers only return error | 158 | * core to the system logs for debugging purposes. Still, it is recommended |
199 | * codes from their resume methods if the device being handled fails to resume | 159 | * that drivers only return error codes from their resume methods in case of an |
200 | * and is not usable any more. | 160 | * unrecoverable failure (i.e. when the device being handled refuses to resume |
161 | * and becomes unusable) to allow us to modify the PM core in the future, so | ||
162 | * that it can avoid attempting to handle devices that failed to resume and | ||
163 | * their children. | ||
164 | * | ||
165 | * It is allowed to unregister devices while the above callbacks are being | ||
166 | * executed. However, it is not allowed to unregister a device from within any | ||
167 | * of its own callbacks. | ||
201 | */ | 168 | */ |
202 | 169 | ||
203 | struct pm_ext_ops { | 170 | struct dev_pm_ops { |
204 | struct pm_ops base; | 171 | int (*prepare)(struct device *dev); |
172 | void (*complete)(struct device *dev); | ||
173 | int (*suspend)(struct device *dev); | ||
174 | int (*resume)(struct device *dev); | ||
175 | int (*freeze)(struct device *dev); | ||
176 | int (*thaw)(struct device *dev); | ||
177 | int (*poweroff)(struct device *dev); | ||
178 | int (*restore)(struct device *dev); | ||
205 | int (*suspend_noirq)(struct device *dev); | 179 | int (*suspend_noirq)(struct device *dev); |
206 | int (*resume_noirq)(struct device *dev); | 180 | int (*resume_noirq)(struct device *dev); |
207 | int (*freeze_noirq)(struct device *dev); | 181 | int (*freeze_noirq)(struct device *dev); |