aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/hibernate.c
diff options
context:
space:
mode:
authorSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>2011-12-07 16:29:54 -0500
committerRafael J. Wysocki <rjw@sisk.pl>2011-12-08 17:22:29 -0500
commitbcda53faf5814c0c6025a0bd47108adfcbe9f199 (patch)
treea8768204a16b24436f33fac00c1bb4dcfb4fafd5 /kernel/power/hibernate.c
parent9b6fc5dc879bc90f765db0e95eefcf123d0d06dd (diff)
PM / Sleep: Replace mutex_[un]lock(&pm_mutex) with [un]lock_system_sleep()
Using [un]lock_system_sleep() is safer than directly using mutex_[un]lock() on 'pm_mutex', since the latter could lead to freezing failures. Hence convert all the present users of mutex_[un]lock(&pm_mutex) to use these safe APIs instead. Suggested-by: Tejun Heo <tj@kernel.org> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel/power/hibernate.c')
-rw-r--r--kernel/power/hibernate.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 605149a6d219..6d6d28870335 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -69,14 +69,14 @@ void hibernation_set_ops(const struct platform_hibernation_ops *ops)
69 WARN_ON(1); 69 WARN_ON(1);
70 return; 70 return;
71 } 71 }
72 mutex_lock(&pm_mutex); 72 lock_system_sleep();
73 hibernation_ops = ops; 73 hibernation_ops = ops;
74 if (ops) 74 if (ops)
75 hibernation_mode = HIBERNATION_PLATFORM; 75 hibernation_mode = HIBERNATION_PLATFORM;
76 else if (hibernation_mode == HIBERNATION_PLATFORM) 76 else if (hibernation_mode == HIBERNATION_PLATFORM)
77 hibernation_mode = HIBERNATION_SHUTDOWN; 77 hibernation_mode = HIBERNATION_SHUTDOWN;
78 78
79 mutex_unlock(&pm_mutex); 79 unlock_system_sleep();
80} 80}
81 81
82static bool entering_platform_hibernation; 82static bool entering_platform_hibernation;
@@ -597,7 +597,7 @@ int hibernate(void)
597{ 597{
598 int error; 598 int error;
599 599
600 mutex_lock(&pm_mutex); 600 lock_system_sleep();
601 /* The snapshot device should not be opened while we're running */ 601 /* The snapshot device should not be opened while we're running */
602 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { 602 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
603 error = -EBUSY; 603 error = -EBUSY;
@@ -665,7 +665,7 @@ int hibernate(void)
665 pm_restore_console(); 665 pm_restore_console();
666 atomic_inc(&snapshot_device_available); 666 atomic_inc(&snapshot_device_available);
667 Unlock: 667 Unlock:
668 mutex_unlock(&pm_mutex); 668 unlock_system_sleep();
669 return error; 669 return error;
670} 670}
671 671
@@ -893,7 +893,7 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
893 p = memchr(buf, '\n', n); 893 p = memchr(buf, '\n', n);
894 len = p ? p - buf : n; 894 len = p ? p - buf : n;
895 895
896 mutex_lock(&pm_mutex); 896 lock_system_sleep();
897 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) { 897 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
898 if (len == strlen(hibernation_modes[i]) 898 if (len == strlen(hibernation_modes[i])
899 && !strncmp(buf, hibernation_modes[i], len)) { 899 && !strncmp(buf, hibernation_modes[i], len)) {
@@ -919,7 +919,7 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
919 if (!error) 919 if (!error)
920 pr_debug("PM: Hibernation mode set to '%s'\n", 920 pr_debug("PM: Hibernation mode set to '%s'\n",
921 hibernation_modes[mode]); 921 hibernation_modes[mode]);
922 mutex_unlock(&pm_mutex); 922 unlock_system_sleep();
923 return error ? error : n; 923 return error ? error : n;
924} 924}
925 925
@@ -946,9 +946,9 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
946 if (maj != MAJOR(res) || min != MINOR(res)) 946 if (maj != MAJOR(res) || min != MINOR(res))
947 goto out; 947 goto out;
948 948
949 mutex_lock(&pm_mutex); 949 lock_system_sleep();
950 swsusp_resume_device = res; 950 swsusp_resume_device = res;
951 mutex_unlock(&pm_mutex); 951 unlock_system_sleep();
952 printk(KERN_INFO "PM: Starting manual resume from disk\n"); 952 printk(KERN_INFO "PM: Starting manual resume from disk\n");
953 noresume = 0; 953 noresume = 0;
954 software_resume(); 954 software_resume();