aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power
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
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')
-rw-r--r--kernel/power/hibernate.c16
-rw-r--r--kernel/power/main.c4
-rw-r--r--kernel/power/suspend.c4
-rw-r--r--kernel/power/user.c16
4 files changed, 20 insertions, 20 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();
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 7d36fb31e4c4..9824b41e5a18 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -116,7 +116,7 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
116 p = memchr(buf, '\n', n); 116 p = memchr(buf, '\n', n);
117 len = p ? p - buf : n; 117 len = p ? p - buf : n;
118 118
119 mutex_lock(&pm_mutex); 119 lock_system_sleep();
120 120
121 level = TEST_FIRST; 121 level = TEST_FIRST;
122 for (s = &pm_tests[level]; level <= TEST_MAX; s++, level++) 122 for (s = &pm_tests[level]; level <= TEST_MAX; s++, level++)
@@ -126,7 +126,7 @@ static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
126 break; 126 break;
127 } 127 }
128 128
129 mutex_unlock(&pm_mutex); 129 unlock_system_sleep();
130 130
131 return error ? error : n; 131 return error ? error : n;
132} 132}
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index d336b27d1104..4fd51beed879 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -42,9 +42,9 @@ static const struct platform_suspend_ops *suspend_ops;
42 */ 42 */
43void suspend_set_ops(const struct platform_suspend_ops *ops) 43void suspend_set_ops(const struct platform_suspend_ops *ops)
44{ 44{
45 mutex_lock(&pm_mutex); 45 lock_system_sleep();
46 suspend_ops = ops; 46 suspend_ops = ops;
47 mutex_unlock(&pm_mutex); 47 unlock_system_sleep();
48} 48}
49EXPORT_SYMBOL_GPL(suspend_set_ops); 49EXPORT_SYMBOL_GPL(suspend_set_ops);
50 50
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 06ea33df8560..98ade217da6c 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -71,7 +71,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
71 struct snapshot_data *data; 71 struct snapshot_data *data;
72 int error; 72 int error;
73 73
74 mutex_lock(&pm_mutex); 74 lock_system_sleep();
75 75
76 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { 76 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
77 error = -EBUSY; 77 error = -EBUSY;
@@ -123,7 +123,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
123 data->platform_support = 0; 123 data->platform_support = 0;
124 124
125 Unlock: 125 Unlock:
126 mutex_unlock(&pm_mutex); 126 unlock_system_sleep();
127 127
128 return error; 128 return error;
129} 129}
@@ -132,7 +132,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)
132{ 132{
133 struct snapshot_data *data; 133 struct snapshot_data *data;
134 134
135 mutex_lock(&pm_mutex); 135 lock_system_sleep();
136 136
137 swsusp_free(); 137 swsusp_free();
138 free_basic_memory_bitmaps(); 138 free_basic_memory_bitmaps();
@@ -146,7 +146,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)
146 PM_POST_HIBERNATION : PM_POST_RESTORE); 146 PM_POST_HIBERNATION : PM_POST_RESTORE);
147 atomic_inc(&snapshot_device_available); 147 atomic_inc(&snapshot_device_available);
148 148
149 mutex_unlock(&pm_mutex); 149 unlock_system_sleep();
150 150
151 return 0; 151 return 0;
152} 152}
@@ -158,7 +158,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
158 ssize_t res; 158 ssize_t res;
159 loff_t pg_offp = *offp & ~PAGE_MASK; 159 loff_t pg_offp = *offp & ~PAGE_MASK;
160 160
161 mutex_lock(&pm_mutex); 161 lock_system_sleep();
162 162
163 data = filp->private_data; 163 data = filp->private_data;
164 if (!data->ready) { 164 if (!data->ready) {
@@ -179,7 +179,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
179 *offp += res; 179 *offp += res;
180 180
181 Unlock: 181 Unlock:
182 mutex_unlock(&pm_mutex); 182 unlock_system_sleep();
183 183
184 return res; 184 return res;
185} 185}
@@ -191,7 +191,7 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
191 ssize_t res; 191 ssize_t res;
192 loff_t pg_offp = *offp & ~PAGE_MASK; 192 loff_t pg_offp = *offp & ~PAGE_MASK;
193 193
194 mutex_lock(&pm_mutex); 194 lock_system_sleep();
195 195
196 data = filp->private_data; 196 data = filp->private_data;
197 197
@@ -208,7 +208,7 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
208 if (res > 0) 208 if (res > 0)
209 *offp += res; 209 *offp += res;
210unlock: 210unlock:
211 mutex_unlock(&pm_mutex); 211 unlock_system_sleep();
212 212
213 return res; 213 return res;
214} 214}