aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/disk.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-07-19 04:47:36 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:42 -0400
commitb10d911749d37dccfa5873d2088aea3f074b9e45 (patch)
tree56bd0ccb2861d7ae562d4e48a737727628358b42 /kernel/power/disk.c
parentc2cf7d87d804c66e063829d5ca739053e901dc15 (diff)
PM: introduce hibernation and suspend notifiers
Make it possible to register hibernation and suspend notifiers, so that subsystems can perform hibernation-related or suspend-related operations that should not be carried out by device drivers' .suspend() and .resume() routines. [akpm@linux-foundation.org: build fixes] [akpm@linux-foundation.org: cleanups] Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Cc: Nigel Cunningham <nigel@nigel.suspend2.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/power/disk.c')
-rw-r--r--kernel/power/disk.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 885c653509c9..324ac0188ce1 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -281,9 +281,16 @@ int hibernate(void)
281{ 281{
282 int error; 282 int error;
283 283
284 mutex_lock(&pm_mutex);
284 /* The snapshot device should not be opened while we're running */ 285 /* The snapshot device should not be opened while we're running */
285 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) 286 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
286 return -EBUSY; 287 error = -EBUSY;
288 goto Unlock;
289 }
290
291 error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
292 if (error)
293 goto Exit;
287 294
288 /* Allocate memory management structures */ 295 /* Allocate memory management structures */
289 error = create_basic_memory_bitmaps(); 296 error = create_basic_memory_bitmaps();
@@ -294,7 +301,6 @@ int hibernate(void)
294 if (error) 301 if (error)
295 goto Finish; 302 goto Finish;
296 303
297 mutex_lock(&pm_mutex);
298 if (hibernation_mode == HIBERNATION_TESTPROC) { 304 if (hibernation_mode == HIBERNATION_TESTPROC) {
299 printk("swsusp debug: Waiting for 5 seconds.\n"); 305 printk("swsusp debug: Waiting for 5 seconds.\n");
300 mdelay(5000); 306 mdelay(5000);
@@ -316,12 +322,14 @@ int hibernate(void)
316 swsusp_free(); 322 swsusp_free();
317 } 323 }
318 Thaw: 324 Thaw:
319 mutex_unlock(&pm_mutex);
320 unprepare_processes(); 325 unprepare_processes();
321 Finish: 326 Finish:
322 free_basic_memory_bitmaps(); 327 free_basic_memory_bitmaps();
323 Exit: 328 Exit:
329 pm_notifier_call_chain(PM_POST_HIBERNATION);
324 atomic_inc(&snapshot_device_available); 330 atomic_inc(&snapshot_device_available);
331 Unlock:
332 mutex_unlock(&pm_mutex);
325 return error; 333 return error;
326} 334}
327 335