diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-12-15 14:59:30 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-12-17 18:27:43 -0500 |
commit | 1eac8111e0763853266a171ce11214da3a347a0a (patch) | |
tree | 9d4cdb27ac6cf063d14b585c84c1ba5c6558a61b /drivers/base/power/generic_ops.c | |
parent | 8ca6d9bcc8d33c592c0855b4b1481bc723ac7e85 (diff) |
PM / Sleep: Merge internal functions in generic_ops.c
After the change that removed the code related to runtime PM
from __pm_generic_call() and __pm_generic_resume() these two
functions need not be separate any more, so merge them.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/power/generic_ops.c')
-rw-r--r-- | drivers/base/power/generic_ops.c | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c index 1b878b955c8a..5a5b154bc1e9 100644 --- a/drivers/base/power/generic_ops.c +++ b/drivers/base/power/generic_ops.c | |||
@@ -97,7 +97,7 @@ int pm_generic_prepare(struct device *dev) | |||
97 | * @event: PM transition of the system under way. | 97 | * @event: PM transition of the system under way. |
98 | * @bool: Whether or not this is the "noirq" stage. | 98 | * @bool: Whether or not this is the "noirq" stage. |
99 | * | 99 | * |
100 | * Execute the suspend/freeze/poweroff/thaw callback provided by the driver of | 100 | * Execute the PM callback corresponding to @event provided by the driver of |
101 | * @dev, if defined, and return its error code. Return 0 if the callback is | 101 | * @dev, if defined, and return its error code. Return 0 if the callback is |
102 | * not present. | 102 | * not present. |
103 | */ | 103 | */ |
@@ -119,9 +119,15 @@ static int __pm_generic_call(struct device *dev, int event, bool noirq) | |||
119 | case PM_EVENT_HIBERNATE: | 119 | case PM_EVENT_HIBERNATE: |
120 | callback = noirq ? pm->poweroff_noirq : pm->poweroff; | 120 | callback = noirq ? pm->poweroff_noirq : pm->poweroff; |
121 | break; | 121 | break; |
122 | case PM_EVENT_RESUME: | ||
123 | callback = noirq ? pm->resume_noirq : pm->resume; | ||
124 | break; | ||
122 | case PM_EVENT_THAW: | 125 | case PM_EVENT_THAW: |
123 | callback = noirq ? pm->thaw_noirq : pm->thaw; | 126 | callback = noirq ? pm->thaw_noirq : pm->thaw; |
124 | break; | 127 | break; |
128 | case PM_EVENT_RESTORE: | ||
129 | callback = noirq ? pm->restore_noirq : pm->restore; | ||
130 | break; | ||
125 | default: | 131 | default: |
126 | callback = NULL; | 132 | callback = NULL; |
127 | break; | 133 | break; |
@@ -211,44 +217,12 @@ int pm_generic_thaw(struct device *dev) | |||
211 | EXPORT_SYMBOL_GPL(pm_generic_thaw); | 217 | EXPORT_SYMBOL_GPL(pm_generic_thaw); |
212 | 218 | ||
213 | /** | 219 | /** |
214 | * __pm_generic_resume - Generic resume/restore callback for subsystems. | ||
215 | * @dev: Device to handle. | ||
216 | * @event: PM transition of the system under way. | ||
217 | * @bool: Whether or not this is the "noirq" stage. | ||
218 | * | ||
219 | * Execute the resume/resotre callback provided by the @dev's driver, if | ||
220 | * defined, and return its error code. Return 0 if the callback is not present. | ||
221 | */ | ||
222 | static int __pm_generic_resume(struct device *dev, int event, bool noirq) | ||
223 | { | ||
224 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | ||
225 | int (*callback)(struct device *); | ||
226 | |||
227 | if (!pm) | ||
228 | return 0; | ||
229 | |||
230 | switch (event) { | ||
231 | case PM_EVENT_RESUME: | ||
232 | callback = noirq ? pm->resume_noirq : pm->resume; | ||
233 | break; | ||
234 | case PM_EVENT_RESTORE: | ||
235 | callback = noirq ? pm->restore_noirq : pm->restore; | ||
236 | break; | ||
237 | default: | ||
238 | callback = NULL; | ||
239 | break; | ||
240 | } | ||
241 | |||
242 | return callback ? callback(dev) : 0; | ||
243 | } | ||
244 | |||
245 | /** | ||
246 | * pm_generic_resume_noirq - Generic resume_noirq callback for subsystems. | 220 | * pm_generic_resume_noirq - Generic resume_noirq callback for subsystems. |
247 | * @dev: Device to resume. | 221 | * @dev: Device to resume. |
248 | */ | 222 | */ |
249 | int pm_generic_resume_noirq(struct device *dev) | 223 | int pm_generic_resume_noirq(struct device *dev) |
250 | { | 224 | { |
251 | return __pm_generic_resume(dev, PM_EVENT_RESUME, true); | 225 | return __pm_generic_call(dev, PM_EVENT_RESUME, true); |
252 | } | 226 | } |
253 | EXPORT_SYMBOL_GPL(pm_generic_resume_noirq); | 227 | EXPORT_SYMBOL_GPL(pm_generic_resume_noirq); |
254 | 228 | ||
@@ -258,7 +232,7 @@ EXPORT_SYMBOL_GPL(pm_generic_resume_noirq); | |||
258 | */ | 232 | */ |
259 | int pm_generic_resume(struct device *dev) | 233 | int pm_generic_resume(struct device *dev) |
260 | { | 234 | { |
261 | return __pm_generic_resume(dev, PM_EVENT_RESUME, false); | 235 | return __pm_generic_call(dev, PM_EVENT_RESUME, false); |
262 | } | 236 | } |
263 | EXPORT_SYMBOL_GPL(pm_generic_resume); | 237 | EXPORT_SYMBOL_GPL(pm_generic_resume); |
264 | 238 | ||
@@ -268,7 +242,7 @@ EXPORT_SYMBOL_GPL(pm_generic_resume); | |||
268 | */ | 242 | */ |
269 | int pm_generic_restore_noirq(struct device *dev) | 243 | int pm_generic_restore_noirq(struct device *dev) |
270 | { | 244 | { |
271 | return __pm_generic_resume(dev, PM_EVENT_RESTORE, true); | 245 | return __pm_generic_call(dev, PM_EVENT_RESTORE, true); |
272 | } | 246 | } |
273 | EXPORT_SYMBOL_GPL(pm_generic_restore_noirq); | 247 | EXPORT_SYMBOL_GPL(pm_generic_restore_noirq); |
274 | 248 | ||
@@ -278,7 +252,7 @@ EXPORT_SYMBOL_GPL(pm_generic_restore_noirq); | |||
278 | */ | 252 | */ |
279 | int pm_generic_restore(struct device *dev) | 253 | int pm_generic_restore(struct device *dev) |
280 | { | 254 | { |
281 | return __pm_generic_resume(dev, PM_EVENT_RESTORE, false); | 255 | return __pm_generic_call(dev, PM_EVENT_RESTORE, false); |
282 | } | 256 | } |
283 | EXPORT_SYMBOL_GPL(pm_generic_restore); | 257 | EXPORT_SYMBOL_GPL(pm_generic_restore); |
284 | 258 | ||