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>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
9b6fc5dc87
commit
bcda53faf5
@ -71,7 +71,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
|
||||
struct snapshot_data *data;
|
||||
int error;
|
||||
|
||||
mutex_lock(&pm_mutex);
|
||||
lock_system_sleep();
|
||||
|
||||
if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
|
||||
error = -EBUSY;
|
||||
@ -123,7 +123,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
|
||||
data->platform_support = 0;
|
||||
|
||||
Unlock:
|
||||
mutex_unlock(&pm_mutex);
|
||||
unlock_system_sleep();
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -132,7 +132,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)
|
||||
{
|
||||
struct snapshot_data *data;
|
||||
|
||||
mutex_lock(&pm_mutex);
|
||||
lock_system_sleep();
|
||||
|
||||
swsusp_free();
|
||||
free_basic_memory_bitmaps();
|
||||
@ -146,7 +146,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)
|
||||
PM_POST_HIBERNATION : PM_POST_RESTORE);
|
||||
atomic_inc(&snapshot_device_available);
|
||||
|
||||
mutex_unlock(&pm_mutex);
|
||||
unlock_system_sleep();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -158,7 +158,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
|
||||
ssize_t res;
|
||||
loff_t pg_offp = *offp & ~PAGE_MASK;
|
||||
|
||||
mutex_lock(&pm_mutex);
|
||||
lock_system_sleep();
|
||||
|
||||
data = filp->private_data;
|
||||
if (!data->ready) {
|
||||
@ -179,7 +179,7 @@ static ssize_t snapshot_read(struct file *filp, char __user *buf,
|
||||
*offp += res;
|
||||
|
||||
Unlock:
|
||||
mutex_unlock(&pm_mutex);
|
||||
unlock_system_sleep();
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -191,7 +191,7 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
|
||||
ssize_t res;
|
||||
loff_t pg_offp = *offp & ~PAGE_MASK;
|
||||
|
||||
mutex_lock(&pm_mutex);
|
||||
lock_system_sleep();
|
||||
|
||||
data = filp->private_data;
|
||||
|
||||
@ -208,7 +208,7 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
|
||||
if (res > 0)
|
||||
*offp += res;
|
||||
unlock:
|
||||
mutex_unlock(&pm_mutex);
|
||||
unlock_system_sleep();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Reference in New Issue
Block a user