diff options
Diffstat (limited to 'kernel/power/disk.c')
-rw-r--r-- | kernel/power/disk.c | 16 |
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 | ||