swsusp: userland interface fixes
Subsystems (2)
PATCH 1/1 swsusp: userland interface fixes
Hi,
This patch contains some minor fixes of the swsusp userland interface:
1) use atomic_add_unless() instead of atomic_dec_and_test()/atomic_inc(),
2) remove a (unnecessary) memory barrier,
3) drop (unnecessary) access_ok() (actually the page will get released when the device is closed, so we don't need to worry if put_user() fails).
Please consider for applying.
Greetings,
Rafael
Signed-off-by Rafael J. Wysocki <[email protected]>
kernel/power/user.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)
kernel/power/user.c +2 -9
@@ -40,10 +40,8 @@ static int snapshot_open(struct inode *i {struct snapshot_data *data; -if (!atomic_dec_and_test (&device_available)) { -atomic_inc (&device_available); +if (!atomic_add_unless (&device_available,-1 ,0 ))return -EBUSY ; - }if ((filp->f_flags &O_ACCMODE ) ==O_RDWR )return -ENOSYS ;
@@ -198,7 +196,6 @@ static int snapshot_ioctl(struct inode *pm_prepare_console (); error =device_suspend (PMSG_FREEZE );if (!error) { -mb (); error =swsusp_resume ();device_resume (); }
@@ -223,10 +220,6 @@ static int snapshot_ioctl(struct inode *break ;case SNAPSHOT_GET_SWAP_PAGE : -if (!access_ok (VERIFY_WRITE , (unsigned long __user *)arg,_IOC_SIZE (cmd))) { - error = -EINVAL ; -break ; - }if (data->swap <0 || data->swap >=MAX_SWAPFILES ) { error = -ENODEV ;break ;
@@ -241,7 +234,7 @@ static int snapshot_ioctl(struct inode * offset =alloc_swap_page (data->swap, data->bitmap);if (offset) { offset <<=PAGE_SHIFT ; -__put_user (offset, (loff_t __user *)arg); + error =put_user (offset, (loff_t __user *)arg); }else { error = -ENOSPC ; }